Use BigModel.io with Claude Code
Point Claude Code at the BigModel.io Anthropic-compatible API with ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, pick GLM, Kimi, DeepSeek or MiniMax models, and fix common errors.
On this page
Claude Code talks the Anthropic Messages protocol. BigModel.io serves it at https://bigmodel.io/v1/messages, so you configure the gateway root and Claude Code adds /v1/messages itself. For OpenAI-protocol code, the base URL is https://bigmodel.io/v1 instead.
| Setting | Value |
|---|---|
ANTHROPIC_BASE_URL |
https://bigmodel.io (no /v1) |
ANTHROPIC_AUTH_TOKEN |
your BigModel.io API key (sk-...), sent as Authorization: Bearer |
ANTHROPIC_MODEL |
a model ID from the model catalog |
ANTHROPIC_DEFAULT_HAIKU_MODEL |
a cheaper model for background tasks |
Anthropic states that Claude Code does not officially support non-Claude models through a gateway. GLM, Kimi, DeepSeek and MiniMax models work through BigModel.io, but Anthropic will not help with problems specific to them, and quality on long agentic tasks varies by model.
#Before you start
- Install Claude Code and confirm
claude --versionworks. - Create a key in API Keys. Its group decides which models and endpoints you can call.
- Check that the key's group serves the Messages endpoint. GLM and DeepSeek groups that are "Chat Completions only" return 404 on
/v1/messages; for those keys, use an OpenAI-protocol tool such as OpenCode or Cline.
This request should return a short reply. Replace glm-5.3 with the model you plan to use:
curl https://bigmodel.io/v1/messages \
-H "Authorization: Bearer $BIGMODEL_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"glm-5.3","max_tokens":64,"messages":[{"role":"user","content":"ping"}]}'#Configure with environment variables
For a single terminal session:
export ANTHROPIC_BASE_URL="https://bigmodel.io"
export ANTHROPIC_AUTH_TOKEN="${BIGMODEL_API_KEY:?Set BIGMODEL_API_KEY first}"
export ANTHROPIC_MODEL="glm-5.3"
# Claude Code also runs small background tasks; point them at a model you can call.
export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.3-flash"
claudeUse ANTHROPIC_AUTH_TOKEN, not ANTHROPIC_API_KEY. ANTHROPIC_API_KEY is sent as x-api-key and needs a one-time approval in interactive mode; if both are set, Claude Code reports an auth conflict. Run unset ANTHROPIC_API_KEY.
#Configure in settings.json
To keep the setting across sessions, add an env block to ~/.claude/settings.json (all projects) or .claude/settings.local.json (one project, not committed):
{
"env": {
"ANTHROPIC_BASE_URL": "https://bigmodel.io",
"ANTHROPIC_AUTH_TOKEN": "sk-your-bigmodel-key",
"ANTHROPIC_MODEL": "glm-5.3",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.3",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.3",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash"
}
}Never put the key in a committed .claude/settings.json. Values in a settings file win over a shell export. Claude Code's opus, sonnet and haiku aliases in /model map to the three ANTHROPIC_DEFAULT_*_MODEL values, and the haiku slot is also used for background tasks, so set all three to models your key can call. ANTHROPIC_SMALL_FAST_MODEL is deprecated.
#VS Code extension
The Claude Code extension for VS Code does not read the variables you export in a terminal. Either:
- put the
envblock above in~/.claude/settings.json, which the extension and the CLI share (recommended), or - add the variables to the extension's
claudeCode.environmentVariablessetting in VS Code.
Also turn on Disable Login Prompt (claudeCode.disableLoginPrompt) so the extension does not ask for a claude.ai sign-in.
Claude Desktop ignores ANTHROPIC_BASE_URL, so it cannot be pointed at BigModel.io this way.
#Choosing a model
Model IDs are lowercase and keep their dots (deepseek-v4-pro, not DeepSeek-V4-Pro). Copy the ID from the model page; availability depends on your key's group.
| Family | Example ANTHROPIC_MODEL |
Notes |
|---|---|---|
| GLM (Zhipu) | glm-5.3 |
glm-5.3-flash suits the haiku slot |
| Kimi (Moonshot) | kimi-k3 |
|
| DeepSeek | deepseek-v4-pro |
deepseek-v4-flash is a cheaper fast option |
| MiniMax | minimax-m3 |
Switch inside a session with /model glm-5.3, or start with claude --model kimi-k3. Try a small task before a long agentic run.
#Context window for non-Claude models
Claude Code does not know these model IDs. It shows a warning that the model "isn't recognized" and assumes a 200k-token context. Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's real context window (from its model page) so automatic compaction starts at the right time:
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=128000 # replace with the model's context windowDo not enable CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY: it keeps only model IDs that contain claude or anthropic, so BigModel.io models will not appear. Use ANTHROPIC_MODEL and the alias variables instead.
#Other useful variables
| Variable | When to set it |
|---|---|
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 |
You get 400 "Extra inputs are not permitted" or a rejected anthropic-beta header |
API_TIMEOUT_MS |
Long requests time out; the default is 600000 (10 minutes) |
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 |
Optional; turns off non-essential traffic to Anthropic |
#Verify the setup
Run /status inside Claude Code. It should show https://bigmodel.io as the Anthropic base URL and an auth token line from your environment or settings. Then send one prompt and confirm the request appears in Usage. A reply alone does not prove the right base URL was used.
#Troubleshooting
403 permission_error: This group does not allow /v1/messages dispatch. The key's group doesn't offer the Anthropic Messages endpoint. Use a key from a group that supports it, or connect your tool through the OpenAI-compatible endpoint instead (OpenCode, Cline). Contact support if you're unsure which group to use.
404 not_found_error: ... platform only supports /v1/chat/completions; /v1/messages is not available. The key belongs to a Chat Completions-only group (GLM or DeepSeek platform). Use a key from a group that serves Messages, or use an OpenAI-protocol tool.
404 on every request. Check ANTHROPIC_BASE_URL. With https://bigmodel.io/v1 the client calls /v1/v1/messages. Remove the /v1.
401 INVALID_API_KEY or API_KEY_REQUIRED. The token is missing or mistyped, or Claude Code is still using a claude.ai login. Check /status, make sure ANTHROPIC_AUTH_TOKEN is set where claude starts, and remove any ANTHROPIC_API_KEY.
503 api_error: No available accounts: no available accounts supporting model: .... The model ID is misspelled, or your key's group does not serve it. List what your key can call with curl https://bigmodel.io/v1/models -H "Authorization: Bearer $BIGMODEL_API_KEY".
400 "Extra inputs are not permitted". Claude Code sent a beta field or anthropic-beta header that the model path rejects. Set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 and restart.
Warning "isn't recognized · context assumed to be 200k tokens". Expected for non-Claude models. Set CLAUDE_CODE_MAX_CONTEXT_TOKENS as shown above.
Main replies work but titles, summaries or subagents fail. Background tasks use the haiku slot. Set ANTHROPIC_DEFAULT_HAIKU_MODEL to a model your key can call.
403 INSUFFICIENT_BALANCE or 429 API_KEY_QUOTA_EXHAUSTED. Top up in Billing or raise the key's quota in API Keys. A 429 rate_limit_exceeded with a message like "api key 5小时限额已用完" means a key spend window is used up; it resets when the window ends.
409 malformed_session_state. The conversation history has thinking blocks or tool IDs the model cannot accept, often after switching models mid-session. Start a new session with /clear.
Settings seem ignored. A settings file beats a shell export, and a project .claude/settings.json or .claude/settings.local.json can override your user file. Run env | grep ANTHROPIC, check the project's settings files, and restart Claude Code after changes.
#Related
- Configure Base URL in Codex, Claude Code, Cursor and Cline — the same settings side by side.
- CC Switch to import a key into Claude Code with one click.
- Codex CLI and OpenCode for OpenAI-protocol terminal agents.
- Errors for every error code.
- API quickstart for keys, billing and first requests.
Updated · View as Markdown