Claude Code API relay: connect it with two variables
As of 2026-11-04, a Claude Code API relay means pointing Claude Code's ANTHROPIC_BASE_URL at a third-party Anthropic-compatible endpoint and calling Claude models billed by that service's API key; on QCode it comes down to two environment variables: ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN.
Updated 2026-11-04
Point this tool at the QCode endpoint — one key for Claude, GPT and Chinese models.
- Billed per token — live rates on /models
- Pay by card (Visa / Mastercard), Apple Pay, Google Pay or crypto
- Self-service: top up and activate instantly
Four takeaways
Protocol and base URL
Claude models are served only through the Anthropic Messages API. The documented value is https://api.qcode.cc/api; the SDK appends /v1/messages itself, so no trailing slash. The three access domains behave the same, and for mainland China the docs recommend asia.qcode.cc.
Key and billing
You create the key in the QCode console and send it as ANTHROPIC_AUTH_TOKEN in a Bearer header. Billing is per token and per-model rates are listed on /models; the Claude models on sale on /models on 2026-11-04 included claude-sonnet-5-5, claude-opus-5-5 and claude-haiku-5-5.
Payment and arrival
The top-up page supports Alipay, WeChat Pay, bank cards (Visa / Mastercard), Apple Pay / Google Pay, SBP and Russian cards, and cryptocurrency (USDT · USDC · BTC · ETH and more). Alipay, WeChat Pay, cards, Apple Pay and Google Pay usually arrive within a minute; SBP and Russian cards can take a few minutes; crypto is checked by hand and credited within one day.
Which features work
Everything the local Claude Code CLI does keeps working: chat, reading and writing files, Bash, MCP, Skills, Hooks, plugins and subagents, with project rules in CLAUDE.md. Features that need a claude.ai sign-in — cloud sessions, Remote Control, voice dictation — do not.
Subscription, official API and gateway key are three things
A subscription is membership in the official apps, an official API key is a metered credential on the developer platform, and a QCode cr_ key is a gateway key that speaks several protocols: the three are independent, they never consume each other's quota, and they can coexist — the same Claude Code can be signed in with a plan or pointed at QCode, whichever credential is currently active. A relay differs from the official API in who bills you and which credential you use, not in the model: Claude still works only over the Anthropic Messages protocol, and OpenAI-compatible endpoints do not serve Claude models.
What the official and QCode docs say
Anthropic's Claude Code docs define an LLM gateway as a proxy your organization runs between Claude Code and the model provider, and list the base URL and the credential as the two variables every gateway connection needs; that page was updated on 2026-10-27. The same documentation set says the CLI and everything that runs locally work on every provider, while features that require a claude.ai sign-in are not reachable from a third-party provider. On the QCode side, the endpoints and API paths page was updated 2026-10-27, the Claude Code tutorial 2026-10-20 and the feature-availability table 2026-11-03.
Timeline
Anthropic released API version 2026-10-21, and the SDKs published the same day (Python SDK 2.0.0, TypeScript SDK 1.0.0 and others) send it by default; if you call the Messages API without an SDK you set the anthropic-version header to 2026-10-21.
The official Claude Code gateway page was updated: it names the base URL and the credential as the two required variables, and states that Remote Control is disabled while ANTHROPIC_BASE_URL points at a non-Anthropic host.
Anthropic raised the maximum request size for the Messages API and the Token Counting API from 32 MB to 128 MB on the first-party Claude API.
Confirmed vs common misconceptions
Confirmed (verifiable word for word)
QCode docs: the documented Claude Code BASE_URL stops at /api and the SDK appends /v1/messages; keys start with cr_ and are created in the console; billing is per token. Anthropic docs: the CLI and everything that runs locally work on every provider, while features that need a claude.ai sign-in are not reachable with a Console API key or from a third-party provider.
Common misconceptions
One: a relay does not unlock claude.ai account features such as Projects, memory or cloud sessions — the official docs mark those as requiring a claude.ai sign-in, and the local equivalent in Claude Code is CLAUDE.md. Two: the base URL takes neither /v1 nor a trailing slash — /api is a path prefix, the SDK appends /v1/messages, and an extra slash yields //v1/messages and a 404. Three: Claude cannot be called through an OpenAI-compatible endpoint — the docs state that OpenAI-compatible endpoints do not serve Claude models, so model_not_available_on_endpoint means the protocol was wrong, while a wrong key returns Invalid API key. Four: if ANTHROPIC_API_KEY is set in your environment, official docs say Claude Code authenticates with that key instead of your subscription and bills API usage.
Official subscription vs a metered API key
Anthropic subscription (Pro / Max / Ultra)
claude.com/pricing and the help centre captured 2026-11-04: Pro is $20 when billed monthly, Max $100 a month, Ultra $200 a month. Plans are metered over a five-hour window and weekly limits, and web, desktop and Claude Code signed in with the plan share one allowance.
Metered API key (QCode or Anthropic Console)
Billed per token, no monthly plan: QCode lists per-model rates on /models; the official API draws down your Console balance. This suits people whose usage is uneven, who do not want a monthly commitment, or who share one key between Claude Code and Codex.
Three steps
① Register at qcode.cc and create the cr_ key in the console. ② Pay on the top-up page; it is fully self-service — after you top up, activation is immediate. ③ Set the two variables: export ANTHROPIC_BASE_URL=https://api.qcode.cc/api and export ANTHROPIC_AUTH_TOKEN=your cr_ key, then run claude, send a message, and use /status to see which base URL and credential are in use. To persist them, put both lines in the env block of a settings file; the official docs warn against keeping the credential in a project settings.json that gets committed. To check the path first, send one POST as the docs describe: 400 or 401 means the path and network are fine, 404 means the prefix is wrong. CC Switch can flip between providers.
Start on QCode
Three steps: register and create the cr_ key, top up, then point ANTHROPIC_BASE_URL at https://api.qcode.cc/api and put the key in ANTHROPIC_AUTH_TOKEN. Billing is per token, with per-model rates on /models. Not ready for a monthly plan? Pay-as-you-go Packs start at $4 for a one-time quota you use within 7 days; if you already have a Personal Plan, add a booster pack when you need more quota.
FAQ
What is the difference between a Claude Code API relay and the official API?
Who bills you and which credential you use — not the model. The official API uses an Anthropic Console key topped up on the official platform; a QCode cr_ key is this gateway's own credential, with rates on /models. The three credential types are independent, never convert into each other, and can coexist: whichever one Claude Code uses depends on what is currently active.
Do I add /v1 or a trailing slash to the base URL?
No. The documented value stops at /api and the SDK appends /v1/messages; with a trailing slash you get //v1/messages and a 404. Both /api and /claude route to the Anthropic Messages protocol, and the docs write /api by default.
Which payment methods work, and how fast does the balance arrive?
Alipay, WeChat Pay, cards, Apple Pay and Google Pay usually arrive within a minute; SBP and Russian cards can take a few minutes; crypto is checked by hand and credited within one day.
Do CLAUDE.md, MCP, Skills and Hooks work?
Yes — these are local capabilities, and the QCode feature-availability table lists them as working (the version updated 2026-11-03 records CLAUDE.md and Hooks as tested). What does not work is the group that needs a claude.ai sign-in: cloud sessions, Remote Control, voice dictation.
Subscription or metered API — which should I pick?
A subscription is metered over a five-hour window and weekly limits shared between chat and terminal; a metered API is billed per token and only accumulates with your requests, without a daily reset. Daily use is covered better by a plan; bursty use or avoiding a monthly commitment fits a metered API key — the docs name exactly that case. If you only chat and write documents inside the official apps, you need no API key at all.
Can one key serve several tools and several people?
Across tools, yes: QCode docs say Codex and Claude Code use the same QCode API key, Codex through the OpenAI Responses endpoint and Claude Code through the Anthropic one — Responses does not serve Claude. For a team the documented shape is the Enterprise plan: 35 concurrent requests per account resource, 3 people per account recommended and up to 7 sharing one.
Sources
Anthropic's Claude Code docs (gateway setup and feature availability, archive-dated 2026-10-27 and 2026-10-30); claude.com/pricing and five support.claude.com articles on Max, Ultra, usage credits, monthly API credits and usage limits (self-dated 2026-10-30); the platform release notes and the API version 2026-10-21 migration guide — all captured 2026-11-04. Also qcode.cc pages /models, /pricing, /recharge and /pay-as-you-go, and docs.qcode.cc pages on endpoints and API paths, the Claude Code tutorial, CC Switch, Codex, feature availability, choosing a plan, payment methods and billing, captured 2026-11-04.
Set one key up first
Payment methods and arrival times are on the top-up page; model availability follows /models.
Related reading
Claude Code one-time quota: no subscription, 7 days
A one-time quota with no subscription; whatever you buy is added to the same key. How that quota is shaped and its concurrency are on the QCode choosing-a-plan page.
How to judge whether an AI API relay is worth using
Publicly checkable selection criteria: protocol compatibility, whether per-model rates and the billing unit are published, payment methods and arrival times.
Claude Code on a third-party API: what works and what doesn't
Local CLI capabilities versus features that need a claude.ai account, item by item.
Crypto payment guide
Nine coins, 56 networks, zero platform fee for AI coding API credits.
The QCode details on this page were checked on 2026-11-04 against qcode.cc and docs.qcode.cc captured that day; Anthropic pages were captured the same day and are self-dated 2026-10-27 to 2026-10-30. Official pages prevail, model availability follows /models.