Use apimodels in Claude Code
Three environment variables point your local Claude Code at apimodels and run claude-opus-5-5 on your balance — reading/writing local files, running commands, cross-file refactors, all executed on your own machine. About 3 minutes.
Configuration values you need
| Variable | Value |
|---|---|
| ANTHROPIC_BASE_URL | https://api.apimodels.app |
| ANTHROPIC_AUTH_TOKEN | Your apimodels API Key (raw — no Bearer prefix needed) |
| ANTHROPIC_MODEL | claude-opus-5-5 |
Important: set ANTHROPIC_BASE_URL to https://api.apimodels.app only — do NOT append /v1/messages. Claude Code appends that automatically.
Two ways to pass the key — pick one (we accept both Authorization: Bearer and x-api-key, so the raw key works directly):
ANTHROPIC_AUTH_TOKEN= the raw key (Claude Code sends it as Bearer). Recommended.ANTHROPIC_API_KEY= the raw key (sent as x-api-key). Set only one of the two.
Step 1 · Install Claude Code
macOS / Linux
curl -fsSL https://claude.ai/install.sh | bashWindows (PowerShell)
irm https://claude.ai/install.ps1 | iexRun claude --version after install; a version number means success. ⚠️ After installing, do NOT log in with an Anthropic account — you will connect with apimodels credentials in the next step.
Step 2 · Set credentials (choose one)
Method A · System environment variables (recommended)
Configure once — every terminal session routes through apimodels.
macOS / Linux
# ~/.zshrc — Method A (recommended)
echo 'export ANTHROPIC_BASE_URL="https://api.apimodels.app"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk_…your_apimodels_key…"' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL="claude-opus-5-5"' >> ~/.zshrc
source ~/.zshrcWindows (PowerShell)
# PowerShell — Method A (recommended)
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://api.apimodels.app", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk_…your_apimodels_key…", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "claude-opus-5-5", "User")After setting these, close all terminal windows and reopen — new windows are required to pick up the variables.
Method B · Claude Code settings file
Takes effect only when running claude; does not touch other programs — cleaner if you want isolation. File: macOS ~/.claude/settings.json; Windows C:\Users\<you>\.claude\settings.json (create it if missing).
// ~/.claude/settings.json — Method B (per-Claude-Code, isolated)
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.apimodels.app",
"ANTHROPIC_AUTH_TOKEN": "sk_…your_apimodels_key…",
"ANTHROPIC_MODEL": "claude-opus-5-5"
}
}Step 3 · Pick the model
Defaults to claude-opus-5-5 (set via ANTHROPIC_MODEL above). Inside a session you can also type /model anytime to switch to another claude- model (e.g. claude-sonnet-5-5).
Step 4 · Verify the connection
Start a session in any project directory and send a “Hello”:
cd your-project
claude- ✅ Normal reply → connected. You can verify usage in your apimodels call logs.
- ❌ Prompted to log in with Anthropic → see Troubleshooting #1 below.
To confirm the endpoint and key work before installing Claude Code, run this curl:
curl -s https://api.apimodels.app/v1/messages \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 16,
"messages": [{ "role": "user", "content": "Reply with exactly: ok" }]
}'What you can do with it: coding scenarios
Claude Code is an agentic coding tool that runs on your own machine. The model (claude-opus-5-5 via apimodels) decides what to do, while reading/writing files and running commands are executed by Claude Code locally — your code never passes through us; only the context you send to the model is transmitted. So local file operations work fully.
Cross-file refactors
“Split this module into three files and update all imports” — it reads the files, edits them, and verifies.
Find & fix bugs
Describe the symptom; it greps the codebase, locates the cause, edits, and runs tests to confirm.
Write tests / run commands
Generate tests, run npm test / build commands, and iterate on the output.
Answer questions about the repo
“How does auth flow work?” — it reads across files and answers with file paths.
Which models work (and what about GPT)
Claude Code only speaks the Anthropic Messages protocol, so inside it you can only use our claude- models (claude-opus-5-5 recommended).
GPT models (such as GPT-6 Sol) use the OpenAI Responses protocol and won't work in Claude Code — for those, use the OpenAI Codex CLI (also operates files locally). Setup at /docs/codex.
| CLI | Model | Local file ops |
|---|---|---|
| Claude Code | claude-opus-5-5 | ✅ |
| OpenAI Codex | gpt-6-sol / gpt-6.1-sol | ✅ |
| Claude Code + GPT | gpt-6-sol / gpt-6.1-sol | ❌ protocol mismatch |
Troubleshooting
| Symptom | Cause / fix |
|---|---|
| Still prompted to log in with Anthropic | Env vars not loaded. Fully close all terminals (including VSCode / Cursor built-in ones) and reopen; do not log in with an Anthropic account. |
| HTTP 401 | Wrong or missing key. Put the raw key in ANTHROPIC_AUTH_TOKEN (we accept Bearer and x-api-key — no Bearer prefix). Re-check the key in your console. |
| model not found | Run /model in-session and pick a supported claude- model (e.g. claude-opus-5-5 / claude-sonnet-5-5). |
| Trying to use a GPT model but it errors | Claude Code does not support Responses-protocol models. Use the Codex CLI — see /docs/codex. |
| Windows — changes not taking effect | Close all terminals (including editor built-in ones), fully quit those apps, and relaunch. |
To inspect the actual requests Claude Code sends, start with claude --debug and review the logs.
Security tips
- Keep your API Key private — never share it in screenshots, chat groups, or repos.
- If settings.json lives inside a project, add .claude/settings.json to .gitignore; files in your home dir (~/.claude/) are safe by default.
- If a key is leaked, reset it immediately in your console.