Three environment variables point your local Claude Code at apimodels and run claude-opus-4-8 on your balance — reading/writing local files, running commands, cross-file refactors, all executed on your own machine. About 3 minutes.
| Variable | Value |
|---|---|
| ANTHROPIC_BASE_URL | https://apimodels.app/api |
| ANTHROPIC_AUTH_TOKEN | Your apimodels API Key (raw — no Bearer prefix needed) |
| ANTHROPIC_MODEL | claude-opus-4-8 |
Important: set ANTHROPIC_BASE_URL to https://apimodels.app/api 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.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.
Configure once — every terminal session routes through apimodels.
macOS / Linux
# ~/.zshrc — Method A (recommended)
echo 'export ANTHROPIC_BASE_URL="https://apimodels.app/api"' >> ~/.zshrc
echo 'export ANTHROPIC_AUTH_TOKEN="sk_…your_apimodels_key…"' >> ~/.zshrc
echo 'export ANTHROPIC_MODEL="claude-opus-4-8"' >> ~/.zshrc
source ~/.zshrcWindows (PowerShell)
# PowerShell — Method A (recommended)
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://apimodels.app/api", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "sk_…your_apimodels_key…", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "claude-opus-4-8", "User")After setting these, close all terminal windows and reopen — new windows are required to pick up the variables.
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://apimodels.app/api",
"ANTHROPIC_AUTH_TOKEN": "sk_…your_apimodels_key…",
"ANTHROPIC_MODEL": "claude-opus-4-8"
}
}Defaults to claude-opus-4-8 (set via ANTHROPIC_MODEL above). Inside a session you can also type /model anytime to switch to another claude- model (e.g. claude-sonnet-4-6).
Start a session in any project directory and send a “Hello”:
cd your-project
claudeTo confirm the endpoint and key work before installing Claude Code, run this curl:
curl -s https://apimodels.app/api/v1/messages \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-opus-4-8",
"max_tokens": 16,
"messages": [{ "role": "user", "content": "Reply with exactly: ok" }]
}'Claude Code is an agentic coding tool that runs on your own machine. The model (claude-opus-4-8 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.
“Split this module into three files and update all imports” — it reads the files, edits them, and verifies.
Describe the symptom; it greps the codebase, locates the cause, edits, and runs tests to confirm.
Generate tests, run npm test / build commands, and iterate on the output.
“How does auth flow work?” — it reads across files and answers with file paths.
Claude Code only speaks the Anthropic Messages protocol, so inside it you can only use our claude- models (claude-opus-4-8 recommended — tool calling / local file ops verified working).
GPT-5.4 / GPT-5.5 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-4-8 | ✅ |
| OpenAI Codex | gpt-5-4 / gpt-5-5 | ✅ |
| Claude Code + GPT | gpt-5-4 / gpt-5-5 | ❌ protocol mismatch |
| 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-4-8 / claude-sonnet-4-6). |
| Trying to use GPT-5.4 / 5.5 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.