Docs
Claude Code
Claude Code treats any Anthropic-format endpoint as a gateway. Two variables point it at Kunavo, 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-...
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.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 authenticates on the bearer, and API_KEY additionally needs a one-time approval prompt in an interactive session before it takes effect.Step by step
- Create a key at
/app/keysand copy it — it is shown once. - Export the two 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'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 September 6, 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 | $2.00 / $10.00 | the default working model — set with /model or ANTHROPIC_MODEL |
claude-opus-5 | $2.00 / $10.00 | planning and architecture-level edits |
claude-haiku-4-5 | $0.40 / $2.00 | the small/fast tier Claude Code uses for background work |
claude-opus-5-fast | $7.00 / $35.00 | same model, faster output, when latency is the constraint |
FAQ
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. 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.