Run Claude Code through WandAPI with two environment variables
WandAPI is a developer-facing Claude API gateway: 0 Anthropic models, Anthropic Messages passed through natively, automatic failover when the official endpoint returns 500 or rate limits. Alipay top-ups, pay as you go, no monthly fee.
# ~/.zshrc / ~/.bashrc
export ANTHROPIC_BASE_URL="https://api.wandapi.com"
export ANTHROPIC_API_KEY="sk-sole-..."
export ANTHROPIC_MODEL="model-id"
claudeWhy a gateway instead of the official endpoint
Not a replacement for Anthropic — a layer on top: reliability, payment and billing, three things the vendor does not solve for you.
Automatic failover on 5xx / rate limits
Each model has several upstream channels. When Anthropic returns 500, overloaded or rate-limited, the gateway switches to a backup before the first frame, so Claude Code never sees the error.
Alipay top-ups, pay as you go
No overseas card, no subscription. 1 Credit = ¥1, billed per use; spend is split per model and per key in the console.
Native protocol, zero-buffer streaming
Anthropic Messages passes straight through with no translation; every SSE frame is forwarded as it arrives, so Claude Code streams exactly like a direct connection.
Connect Claude Code in three steps
Three steps, no changes to Claude Code itself.
Sign up for free credits
Register with an email and receive trial Credits — enough to wire up a real project.
Create an API key
Console → API Keys → New. Give the key a budget, restrict models or channels if you like.
Point at WandAPI and start Claude Code
Swap the base URL for WandAPI and the key for the one you just created; everything else stays.
# ~/.zshrc / ~/.bashrc
export ANTHROPIC_BASE_URL="https://api.wandapi.com"
export ANTHROPIC_API_KEY="sk-sole-..."
export ANTHROPIC_MODEL="model-id"
claudeCommon Claude Code errors and how the gateway handles them
These errors come from the official Anthropic API. Through WandAPI the gateway retries and fails over before the first frame, so Claude Code usually never shows them.
API Error: 500 Internal Server ErrorOfficial server fault
An occasional 5xx on the Anthropic side, unrelated to your request. WandAPI: a 5xx before the first frame triggers an immediate retry on a backup channel; the client never notices.
API Error: Rate limit reachedOfficial RPM / TPM quota hit
One account ran out of requests or tokens per minute. WandAPI: several upstream keys share the quota; when one returns 429 the next one takes over, no waiting for the window to reset.
Overloaded error (529)Official overload
Anthropic sheds load at peak times. WandAPI: channels are scheduled by health; an overloaded channel is demoted and requests go to a healthy one.
Stream idle timeout – partial responseStream stalled mid-way
No new frame for too long, so Claude Code disconnects. WandAPI: upstream heartbeat frames are forwarded immediately with no buffering; interruptions after the first frame are retried by Claude Code itself.
FAQ
Is a Claude Code gateway safe? Can anyone see my code?
Keys, emails and other sensitive strings are masked before forwarding; transport is encrypted end to end; your requests are never used to train any model. Keys can be limited to models and budgets and revoked in one click.
How is this different from calling Anthropic directly?
Same protocol (Messages, passed through natively), same models, plus three things: automatic failover when the official API fails, Alipay top-ups with CNY billing, and per-key usage and budget control.
Does it work with Codex and Gemini CLI too?
Yes. OpenAI Responses and Gemini generateContent are supported as well — point each tool at the WandAPI base URL. All tools share one API key and one balance.
How do I top up, and is there a minimum?
Console → Wallet, Alipay accepted; 1 Credit = ¥1, billed per use, no monthly fee or minimum. You get an email before the balance runs out.
Two environment variables and Claude Code runs reliably
Free credits on sign-up, pay as you go, no monthly fee.