Usage in China: Point to the Gateway, No VPN Required
# ~/.zshrc / ~/.bashrc / PowerShell 配置文件
export ANTHROPIC_BASE_URL=https://aiprimetech.io
export ANTHROPIC_API_KEY=你的网关密钥
claude
Claude Code reads these two variables just like the official SDK. Requests go to the gateway instead of api.anthropic.com, allowing direct connections from networks in China. Enter the bare domain name without /v1. After setting them, reopen your terminal and use /status in a session to confirm. The VS Code extension and desktop app read the environment of the shell that launches them. After changing the configuration, fully quit the editor and launch it again from a new terminal.
When You Need a Proxy
You only need one if your network connection to the gateway itself is unstable. Configure it just as you would for other command-line tools:
export HTTPS_PROXY=http://127.0.0.1:7890
export HTTP_PROXY=http://127.0.0.1:7890
If /login OAuth login times out ("timeout of 15000ms exceeded"), the cause is usually a proxy or DNS issue; logging in with an API key bypasses OAuth entirely.
Model Configuration
export ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-5
export ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-5
export ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5
Claude Code works with tiers (Sonnet / Opus / Haiku), and these three variables determine the specific model used for each tier. The Haiku tier matters more than it may seem: Claude Code uses it for small tasks in every session, so pointing it to a cheaper model can save a lot. The gateway currently offers 33 Claude model IDs, all selectable in/model .
Where to Find Configuration Files
CLAUDE.md(project root) — project memory: build and test commands, conventions;CLAUDE.local.mdcontains personal notes and is not committed to the repository..claude/settings.json(project) /~/.claude/settings.json(global) — permissions, hooks, environment variables, statusLine..claude/agents/— subagent definitions;.claude/skills/and~/.claude/skills/— skills..mcp.json— MCP server configuration shared by the project.
Troubleshooting Configuration Errors
- 404 with logs containing
/v1/v1/messages→ BASE_URL has an extra/v1。 - 401 / invalid key → the key and address do not match: a gateway address requires a gateway key.
- Logged in with Max but still charged per token → ANTHROPIC_API_KEY is still set in the environment; the key takes priority over the login. Unset it if you do not want to use it.
- Model not found → that ID is not in the current endpoint's
/v1/modelslist. - Exits on startup after editing settings.json → JSON syntax error (an extra comma); check it with a validator.
Costs
Pointing to the gateway also changes billing: credits are sold at 7.69231 times their face value, so $13 gets you $100 in credits; heavy users can choose unlimited plans starting at $0.80. See the pricing page for details.
Try It Free First
New accounts using the promo code CLAUDECODE receive $5 in API credit upon signing up, with no card required — enough to run Claude Code for an evening. The same Claude models, with just two lines of environment variables to switch.
export ANTHROPIC_BASE_URL=https://aiprimetech.io
export ANTHROPIC_API_KEY=your_keyFrequently Asked Questions
Can I use Claude Code in China?
Yes. Claude Code supports a custom API address (ANTHROPIC_BASE_URL). Point it to our gateway for a direct connection from networks in China, with no VPN, overseas account, or bank card required.
How do I configure a proxy for Claude Code?
Set the HTTPS_PROXY / HTTP_PROXY environment variables. However, most users do not need a proxy after pointing to the gateway.
Should I add /v1 to ANTHROPIC_BASE_URL?
No. The SDK appends /v1/messages automatically; adding an extra path segment results in 404.
Run Claude Code Through the Gateway
The same models, two lines of environment variables, and credits topped up at 7.69231 times their face value, or choose an unlimited plan. New accounts can get $5 in API credit with promo code CLAUDECODE.
Get an API Key View PlansAI Prime Tech is an independent API gateway and is not affiliated with, endorsed by, or sponsored by Anthropic. “Claude” and “Claude Code” are trademarks of Anthropic. Claude Code features described here follow Anthropic’s public documentation at the time of writing and change frequently; prices and model lists on this page are read from this gateway’s live settings.