Docs
Claude Code
Claude Code treats any Anthropic-format endpoint as a gateway. Two variables point it at Kunavo, three more pin models Kunavo serves, the install is untouched, and every session bills per token from your balance instead of a subscription.
Two environment variables — ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN — move Claude Code onto pay-as-you-go without changing the install.
# One terminal session
export ANTHROPIC_BASE_URL=https://api.kunavo.com # origin, no /v1
export ANTHROPIC_AUTH_TOKEN=sk-kn-...
# Pin models Kunavo serves. Claude Code's default and its opus/sonnet aliases
# follow Anthropic's newest models; the sonnet alias asks for Sonnet 5.5,
# which Kunavo does not serve — unpinned, /model sonnet 404s.
export ANTHROPIC_MODEL=claude-sonnet-5
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5-5
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5
claudeANTHROPIC_BASE_URL is the origin. Claude Code appends /v1/messages itself — Anthropic's own verification snippet is curl "$ANTHROPIC_BASE_URL/v1/messages" — so a value ending in /v1 produces requests to /v1/v1/messages and a 404. This is the single most common setup failure; the ANTHROPIC_BASE_URL page covers the rest of them.sonnet alias asks for Sonnet 5.5 and the haiku alias for Haiku 5.5 (from v2.1.293), neither of which Kunavo serves, so /model sonnet, /model haiku and subagents set to those aliases 404 unless they are pinned too. ANTHROPIC_MODEL sets the session model; ANTHROPIC_DEFAULT_OPUS_MODEL covers /model opus (Opus 5.5 needs Claude Code v2.1.280 or later), ANTHROPIC_DEFAULT_SONNET_MODEL covers /model sonnet, and ANTHROPIC_DEFAULT_HAIKU_MODEL covers /model haiku plus the background calls. Any id from GET /v1/models works.ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY. The two variables pick a header: AUTH_TOKEN sends Authorization: Bearer, API_KEY sends x-api-key. Kunavo reads either, but API_KEY needs a one-time approval prompt in an interactive session before it takes effect, and AUTH_TOKEN does not.sk-kn-) and add credit from $10 — calls are paid from that balance, and failed calls are not billed. The dashboard then opens on the Claude Code setup.Step by step
- Create a key at
/app/keysand copy it — it is shown once. - Export the variables above for the session, or persist them in the
envblock of~/.claude/settings.json:{"env":{"ANTHROPIC_BASE_URL":"https://api.kunavo.com","ANTHROPIC_AUTH_TOKEN":"sk-kn-...","ANTHROPIC_MODEL":"claude-sonnet-5","ANTHROPIC_DEFAULT_OPUS_MODEL":"claude-opus-5-5","ANTHROPIC_DEFAULT_SONNET_MODEL":"claude-sonnet-5","ANTHROPIC_DEFAULT_HAIKU_MODEL":"claude-haiku-4-5"}}. Anthropic's docs are explicit that the credential does not belong in a project's.claude/settings.json— that file gets committed. - Run
claudeand open the Status tab. A line namingAuth tokenconfirms the gateway credential is active; aLogin methodline naming a claude.ai account means the variable was not picked up. - For the VS Code extension the variables go in
claudeCode.environmentVariablesin VS Code's own user settings — the extension checks credentials before it launches, so~/.claude/settings.jsonreaches the spawned process but not that check.
Checked against Anthropic's “Connect Claude Code to an LLM gateway” on October 3, 2026. Third-party settings move; if a field name here no longer matches what you see, that page is the authority, not this one.
Verify before you debug the client
One request settles whether a failure is the endpoint, the key, or the configuration file. If this returns JSON, the same base URL and key work in Claude Code.
# Settles whether a failure is the endpoint, the key, or the client.
curl -sS https://api.kunavo.com/v1/messages \
-H "Authorization: Bearer sk-kn-..." \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-5","max_tokens":16,"messages":[{"role":"user","content":"ping"}]}'Which model id to put in the field
Every text model is reachable as a model id — the live list is GET /v1/models, and the catalog with prices is on the models page. Rates are USD per 1M tokens, input / output.
| Model id | Kunavo in / out | Where it fits in Claude Code |
|---|---|---|
claude-sonnet-5 | $1.40 / $7.00 | the default working model — set with /model or ANTHROPIC_ |
claude-opus-5-5 | $2.80 / $14.00 | planning and architecture-level edits |
claude-haiku-4-5 | $0.70 / $3.50 | the haiku alias and Claude Code's own background calls — pin it with ANTHROPIC_ |
claude-fable-5 | $7.00 / $35.00 | the frontier tier, for the plans that are worth its rate |
Frequently asked questions
How do I use Claude Code without a Claude subscription?
Set ANTHROPIC_BASE_URL to an Anthropic-format endpoint and ANTHROPIC_AUTH_TOKEN to that endpoint's key, and pin ANTHROPIC_MODEL to a model the endpoint serves — Claude Code's built-in default may not be one. Claude Code then authenticates to the endpoint instead of claude.ai, and usage is billed per token by whoever owns that credential rather than against a subscription plan. Anthropic documents this as gateway mode; the saved claude.ai login stays on disk, unused, and returns as soon as the variables are unset.
Should ANTHROPIC_BASE_URL include /v1?
No. Claude Code appends the route itself, so the variable is the origin — https://api.kunavo.com, not https://api.kunavo.com/v1. Anthropic's own verification command is curl "$ANTHROPIC_BASE_URL/v1/messages", which shows the concatenation directly. A base URL that already ends in /v1 sends requests to /v1/v1/messages and returns 404.
What is the difference between ANTHROPIC_AUTH_TOKEN and ANTHROPIC_API_KEY?
They put the credential in different HTTP headers: ANTHROPIC_AUTH_TOKEN sends Authorization: Bearer, ANTHROPIC_API_KEY sends x-api-key. A key in the wrong variable reaches the endpoint in a header it does not read and the request fails with 401. If a gateway's documentation says "bearer token", use ANTHROPIC_AUTH_TOKEN; if it says "API key" or "x-api-key", use ANTHROPIC_API_KEY.
Which Claude Code features stop working behind a custom base URL?
Remote Control and voice dictation both need a claude.ai identity and are unavailable while a gateway credential is set; Remote Control is additionally disabled whenever ANTHROPIC_BASE_URL points at a non-Anthropic host. The fast-mode availability check also goes directly to api.anthropic.com rather than following the base URL. Everything in the core loop — the agent, tools, subagents, MCP servers — runs on the Messages API and is unaffected.