Coding tools
Claude Code setup: point it at a custom Anthropic base URL
In short: Claude Code is a coding agent that runs on our gateway once ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are set and model ids are pinned; verify with /status.
On this page
https://api.oneaiapikey.comClaude Code is a coding agent that speaks the Anthropic Messages API, and so does our gateway. That means no proxy scripts, no wrappers and no patched binaries: you set two environment variables and Claude Code sends its requests to us instead of to Anthropic. Usage is deducted from your prepaid balance at the published per-model rates.
What do I need to use Claude Code with the gateway?
Using Claude Code with the gateway needs three things:
- Claude Code installed and working in your terminal (any recent version).
- An account with a balance above $0 (the sign-up credit pays for Claude models too; when it runs out, add $1 or more). Create an account if you don’t have one.
- An API key from the API keys page. Keys start with
sk-. Copy it once and keep it somewhere safe.
How do I set the base URL and token?
Set ANTHROPIC_BASE_URL to the gateway and ANTHROPIC_AUTH_TOKEN to your key: Claude Code reads the first to decide where requests go and the second for the credential, which it sends as an Authorization: Bearer header. Use the gateway origin without /v1: Claude Code appends /v1/messages itself.
Start with a quick test in a single terminal session:
export ANTHROPIC_BASE_URL=https://api.oneaiapikey.com
export ANTHROPIC_AUTH_TOKEN=sk-your-key-here$env:ANTHROPIC_BASE_URL = "https://api.oneaiapikey.com"
$env:ANTHROPIC_AUTH_TOKEN = "sk-your-key-here"Then run claude from that same terminal so it inherits the variables.
How do I make it permanent with settings.json?
Put the values in the env block of your user settings file to make them permanent. Shell variables vanish when the terminal closes, and editors launched from a dock or Start menu never see them. For a setup that works everywhere, put the values in the env block of your user settings file: ~/.claude/settings.json on macOS and Linux, %USERPROFILE%\.claude\settings.json on Windows.
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.oneaiapikey.com",
"ANTHROPIC_AUTH_TOKEN": "sk-your-key-here",
"ANTHROPIC_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5"
}
}If the file already exists, merge the env keys into it rather than replacing the whole file. When a shell variable and the settings file disagree, the settings file wins.
Never put your key in a project’s
.claude/settings.json. That file is usually committed to git and shared with everyone who clones the repository. Use the user-level file, or a project’s.claude/settings.local.jsonthat is listed in your gitignore.
Using the Claude Code extension for VS Code? Add the same two variables under claudeCode.environmentVariables in your VS Code user settings, because the extension checks credentials there before it starts.
Which models should I choose in Claude Code?
Choose models with ANTHROPIC_MODEL, which sets the default for the session. The three ANTHROPIC_DEFAULT_*_MODEL variables decide what Claude Code uses when you (or a sub-agent) pick the Opus, Sonnet or Haiku slot in /model. The Haiku slot also handles lightweight background work such as session titles, so pointing it at the fast model keeps those calls cheap.
Over the Anthropic route we serve Claude models only, which is also the only combination Claude Code is designed for. Current rates (USD per 1M tokens):
| Model id | Good for | Input | Output |
|---|---|---|---|
claude-opus-5-5 | Agentic coding, Large refactors, Complex reasoning | $2.80 | $14 |
claude-sonnet-5-5 | Daily coding, Coding agents, Code review | $1.40 | $7 |
claude-haiku-4-5 | Sub-agents, Extraction, Chat | $1 | $5 |
A practical default: Sonnet for everyday work, switch to Opus with /model for a hard refactor, and leave Haiku on background and sub-agent duty. See the full list on the models page.
How do I verify Claude Code is using the gateway?
Verify the connection by first testing the key and URL directly, outside Claude Code. A JSON reply containing "content" means the gateway accepted your key:
curl -sS "$ANTHROPIC_BASE_URL/v1/messages" \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-haiku-4-5","max_tokens":16,"messages":[{"role":"user","content":"Say hi"}]}'Invoke-RestMethod -Method Post -Uri "$env:ANTHROPIC_BASE_URL/v1/messages" `
-Headers @{ "Authorization" = "Bearer $env:ANTHROPIC_AUTH_TOKEN"; "anthropic-version" = "2023-06-01" } `
-ContentType "application/json" `
-Body '{"model":"claude-haiku-4-5","max_tokens":16,"messages":[{"role":"user","content":"Say hi"}]}'Then start claude, send any prompt, and run /status. The Anthropic base URL line should show https://api.oneaiapikey.com, and an Auth token line should name ANTHROPIC_AUTH_TOKEN. If both are there and the prompt got an answer, you’re done. Your console’s usage log will show the request within a few seconds.
How do I fix common Claude Code errors?
The common Claude Code errors and their fixes are listed below.
401 Unauthorized. The key is wrong, revoked, or was sent in a header the gateway didn’t expect. Re-copy the key from the console, check for stray spaces or quotes, and confirm you used ANTHROPIC_AUTH_TOKEN. If you set ANTHROPIC_API_KEY instead, Claude Code asks you once to approve it; a previously declined key is silently ignored until you enable it again under /config.
Claude Code still asks me to log in. The variables didn’t reach the process. Put them in ~/.claude/settings.json (the user-level file is read before first-run setup) or export them in the same terminal you launch claude from. If you also have a saved claude.ai login, startup may warn about two credential sources: run /logout to use the gateway key only.
404 or “not found” on every request. Almost always a doubled path. ANTHROPIC_BASE_URL must be https://api.oneaiapikey.com with no trailing /v1 and no trailing slash; otherwise requests go to /v1/v1/messages.
Model not found / no available channel. The id is misspelled or isn’t served on the Anthropic route. Use the exact ids from the table above, all lowercase. Non-Claude models (GPT, Grok, DeepSeek) are available through our OpenAI-compatible endpoint, not through Claude Code.
Timeouts or a request cut off after about 100 seconds. Claude Code streams by default, which keeps long generations alive. If you call the API from your own scripts, send "stream": true for long outputs; proxies along the way drop idle non-streaming requests at roughly 100 seconds.
Out of balance. Requests fail once credits hit zero. Top up from the console; your keys and settings keep working, no restart needed.
Next steps
Want to use the same key elsewhere? The quickstart covers raw API calls and SDKs, and the other tool guides cover OpenAI-format tools like Codex CLI and Cursor. Check current pricing before a long agentic session, and keep an eye on the usage log in the console.