The short answer: why it works
You can use Claude Code with DeepSeek, Kimi, GLM, Qwen, and MiniMax without installing a third-party proxy or modifying the CLI. It works because all five providers publish official endpoints that speak Anthropic's Messages API format natively.
Claude Code separates the local terminal harness (reading files, editing code, running shell commands, and managing context) from the remote language model. When you change two environment variables—where the request goes and how it authenticates—Claude Code sends its standard Anthropic-formatted requests to the new provider instead of Anthropic's servers.
These compatible endpoints are maintained by each model provider, not by Anthropic. Anthropic's documentation states that it does not support or guarantee Claude Code when routed to non-Claude models. Always test a provider on a small task before relying on it for production work.
How the configuration works
Every Anthropic-compatible provider setup relies on the same group of Claude Code environment variables. You can export them in your shell profile or place them inside the env block of your Claude Code settings file.
ANTHROPIC_BASE_URL: Points Claude Code at the provider's Anthropic-compatible endpoint instead ofhttps://api.anthropic.com.ANTHROPIC_AUTH_TOKEN: Holds your provider API key. Claude Code sends this value as anAuthorization: Bearerheader.ANTHROPIC_MODEL: Sets the primary active model for your session.ANTHROPIC_DEFAULT_OPUS_MODEL,ANTHROPIC_DEFAULT_SONNET_MODEL, andANTHROPIC_DEFAULT_HAIKU_MODEL: Map Claude Code's internal model tiers (used when you switch aliases or when Claude Code runs background tasks) to specific model IDs on your chosen provider.CLAUDE_CODE_SUBAGENT_MODEL: Sets the default model for subagents that are not assigned a model another way.ANTHROPIC_DEFAULT_FABLE_MODEL: Maps thefablealias. Moonshot's guide sets it too, so set it if your provider's guide does.
Putting these variables in ~/.claude/settings.json is the cleanest approach for a single default provider. It applies every time you launch claude, including background subagents.
- Use
ANTHROPIC_AUTH_TOKEN, notANTHROPIC_API_KEY: Provider guides useANTHROPIC_AUTH_TOKEN. Leaving an oldANTHROPIC_API_KEYexported in your shell causes authentication conflicts because Claude Code sends it as anx-api-keyheader. - Clear saved logins: If you previously signed in with a claude.ai subscription, run
/logoutinside Claude Code so your token and base URL take over cleanly. - Keep keys out of Git: Put credentials in
~/.claude/settings.json(user scope) or.claude/settings.local.json(git-ignored project scope). Never put API keys in a shared project.claude/settings.jsonfile that gets committed to version control. - Mind variable precedence: When the same variable is set in both your shell and a settings file
envblock, Claude Code applies the settings file value in most sessions. Providers such as MiniMax and Moonshot still recommend clearing oldexport ANTHROPIC_*lines from~/.zshrcor~/.bashrcfirst, because stale values can conflict with the new setup.
DeepSeek setup
DeepSeek provides an official Anthropic-compatible endpoint at https://api.deepseek.com/anthropic. Its API documentation includes a dedicated Claude Code integration guide and supports automatic model name mapping if you pass standard Claude aliases.
Create an API key in the DeepSeek Platform console, then add the configuration from DeepSeek's Claude Code guide to ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "YOUR_DEEPSEEK_API_KEY",
"ANTHROPIC_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-flash",
"CLAUDE_CODE_EFFORT_LEVEL": "max",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "786432"
}
}
- Available models: DeepSeek's Anthropic endpoint supports
deepseek-flashanddeepseek-v4-pro. - Built-in alias fallback: DeepSeek notes that if an unmapped
claude-*model name reaches its endpoint, names starting withclaude-opusare automatically mapped todeepseek-v4-pro, andclaude-sonnetorclaude-haikunames are mapped todeepseek-flash. Non-Claude model names that DeepSeek does not recognize return a400error. - Context suffix: Appending
[1m]tells Claude Code to treat the model as having a 1M context window rather than capping sessions at 200k.
Kimi (Moonshot AI) setup
Moonshot AI serves Kimi models (including Kimi K3) through an Anthropic-compatible endpoint at https://api.moonshot.ai/anthropic. You can generate an API key in the Kimi platform console at platform.kimi.ai.
Moonshot's official Claude Code guide maps every Claude Code model tier in ~/.claude/settings.json so background tasks and subagents do not fall back to unmapped Claude model names:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.moonshot.ai/anthropic",
"ANTHROPIC_AUTH_TOKEN": "YOUR_MOONSHOT_API_KEY",
"ANTHROPIC_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "kimi-k3[1m]",
"CLAUDE_CODE_SUBAGENT_MODEL": "kimi-k3[1m]",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
"CLAUDE_CODE_EFFORT_LEVEL": "max"
}
}
- Model and thinking: Moonshot's guide uses
kimi-k3[1m]for every tier. Kimi K3 always reasons, so no separate thinking parameter is needed; control reasoning effort withCLAUDE_CODE_EFFORT_LEVEL. - China mainland: Moonshot's China-site guide (
platform.kimi.com) useshttps://api.moonshot.cn/anthropic. The base URL must match the platform where your key was created.
GLM (Z.ai / Zhipu) setup
GLM models are offered internationally through Z.ai (docs.z.ai) and in mainland China through Zhipu BigModel (open.bigmodel.cn). Both platforms publish Claude Code setup guides for the GLM Coding Plan, a subscription for agentic tools like Claude Code.
For international users, register at Z.ai, create an API key, and point Claude Code at https://api.z.ai/api/anthropic:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_AUTH_TOKEN": "YOUR_ZAI_API_KEY",
"API_TIMEOUT_MS": "3000000",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "GLM-5.3-Flash",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "GLM-5.3-Flash",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "GLM-5.3-Flash"
}
}
- International vs. China mainland endpoints: Use
https://api.z.ai/api/anthropicwith a Z.ai account. If your account and API key were created on Zhipu's mainland China platform (open.bigmodel.cn), usehttps://open.bigmodel.cn/api/anthropicinstead, as shown in Zhipu's own Claude Code guide. - Automated helper: Z.ai also publishes a CLI helper (
npx @z_ai/coding-helper) that helps set up Claude Code for the GLM Coding Plan. - Model IDs: Check your Z.ai console or Coding Plan documentation for the current model names on your tier (such as
GLM-5.3-Flashorglm-5.3[1m]).
Qwen (Alibaba Cloud Model Studio) setup
Alibaba Cloud Model Studio (DashScope) provides Anthropic-compatible endpoints for Qwen models. Unlike providers with a single static URL, Alibaba Cloud's current endpoints depend on your billing mode (Token Plan, Coding Plan, or Pay-as-you-go Workspace) and your selected region.
For international accounts (Singapore, ap-southeast-1), Alibaba Cloud Model Studio's Claude Code guide documents the following Token Plan configuration:
{
"env": {
"ANTHROPIC_BASE_URL": "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
"ANTHROPIC_AUTH_TOKEN": "YOUR_MODEL_STUDIO_API_KEY",
"ANTHROPIC_MODEL": "auto",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8-flash",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen4-max-preview",
"CLAUDE_CODE_SUBAGENT_MODEL": "auto",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "983616"
}
}
If you use a standard pay-as-you-go Workspace key rather than a Token Plan key, your base URL includes your Workspace ID and region:
{
"env": {
"ANTHROPIC_BASE_URL": "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",
"ANTHROPIC_AUTH_TOKEN": "YOUR_DASHSCOPE_API_KEY",
"ANTHROPIC_MODEL": "qwen3.7-max",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.6-flash",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.7-max",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.7-max",
"CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.7-max"
}
}
- Match key type to base URL: Each Model Studio plan uses its own base URL and a dedicated API key. Using a key with the wrong plan's URL returns a
401 invalid_api_keyerror. For mainland China, Alibaba's China-site guide uses thecn-beijingregion (for examplehttps://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic) andhttps://coding.dashscope.aliyuncs.com/apps/anthropicfor Coding Plan keys. The international Coding Plan URL ishttps://coding-intl.dashscope.aliyuncs.com/apps/anthropic. - Alternative pay-as-you-go URL: If the workspace URL returns a 401, Alibaba's FAQ lists
https://dashscope-intl.aliyuncs.com/apps/anthropic(international) as an alternative. Always copy the exact URL shown in your Model Studio console for your plan.
MiniMax setup
MiniMax offers an official Anthropic-compatible endpoint at https://api.minimax.io/anthropic for international accounts. MiniMax's Claude Code documentation supports both manual ~/.claude/settings.json configuration and a one-command CLI setup wizard (npx -y mmx-cli@latest agent setup).
Before editing the file, MiniMax recommends clearing conflicting variables by running unset ANTHROPIC_AUTH_TOKEN and unset ANTHROPIC_BASE_URL in your terminal so exported shell variables do not override your settings file. Then add the configuration from MiniMax's docs:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.minimax.io/anthropic",
"ANTHROPIC_AUTH_TOKEN": "YOUR_MINIMAX_API_KEY",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "524288",
"CLAUDE_CODE_EFFORT_LEVEL": "max",
"ANTHROPIC_MODEL": "MiniMax-M3.1-Flash[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "MiniMax-M3.1-Flash[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "MiniMax-M3.1-Flash[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "MiniMax-M3.1-Flash[1m]"
}
}
- China mainland endpoint: International accounts use
https://api.minimax.io/anthropic. MiniMax's China-site guide (platform.minimax.cn) useshttps://api.minimax.cn/anthropicwith the same model names.
Provider endpoint summary
Use the cards and table below to compare the official international endpoints. Because model IDs update frequently, check each provider's documentation link for its newest model names.
https://api.deepseek.com/anthropicSupports deepseek-flash and deepseek-v4-pro, plus automatic claude-* alias fallback.https://api.moonshot.ai/anthropicSupports Kimi K3 with 1M context window support.https://api.z.ai/api/anthropicInternational endpoint for GLM Coding Plan and API keys (mainland China uses open.bigmodel.cn).https://...maas.aliyuncs.com/apps/anthropicRegional and plan-specific endpoints for Qwen models on Alibaba Cloud Model Studio.https://api.minimax.io/anthropicSupports MiniMax M-series models via manual config or mmx-cli setup wizard.| Provider | International ANTHROPIC_BASE_URL | Mainland China Endpoint | Official Guide |
|---|---|---|---|
| DeepSeek | https://api.deepseek.com/anthropic | Same endpoint | DeepSeek Docs |
| Kimi (Moonshot) | https://api.moonshot.ai/anthropic | https://api.moonshot.cn/anthropic | Kimi Docs |
| GLM (Z.ai / Zhipu) | https://api.z.ai/api/anthropic | https://open.bigmodel.cn/api/anthropic | Z.ai Docs |
| Qwen (Alibaba Cloud) | Plan/workspace URL in ap-southeast-1 | Plan/workspace URL in cn-beijing (see Alibaba's China-site guide) | Model Studio Docs |
| MiniMax | https://api.minimax.io/anthropic | https://api.minimax.cn/anthropic | MiniMax Docs |
Switching between providers cleanly
Editing ~/.claude/settings.json by hand every time you want to swap between DeepSeek, Kimi, GLM, or official Claude quickly gets tedious. Because Claude Code supports the --settings command-line flag, you can keep each provider in its own JSON file and pick one at launch.
According to Claude Code's settings precedence rules, command-line claude --settings overrides user settings (~/.claude/settings.json) and project settings for that session.
Create a separate JSON file per provider
Save your provider configs as
~/.claude/deepseek.json,~/.claude/kimi.json,~/.claude/glm.json, and so on. Restrict permissions withchmod 600 ~/.claude/*.jsonso other local users cannot read your keys.Add shell aliases
Add short aliases to your
~/.zshrcor~/.bashrcfile that pass the matching file toclaude --settings.Verify with
/statusWhen you start a session with one of your aliases, run
/statusto confirm the expected base URL and model are active.
alias claude-ds="claude --settings ~/.claude/deepseek.json"
alias claude-kimi="claude --settings ~/.claude/kimi.json"
alias claude-glm="claude --settings ~/.claude/glm.json"
alias claude-minimax="claude --settings ~/.claude/minimax.json"
To keep this clean, avoid exporting ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, or ANTHROPIC_API_KEY globally in your shell profile, so stale values from an old setup cannot conflict with the provider file you pick. Run /status to see which base URL and credential are active.
Limitations to keep in mind
Pointing Claude Code at a third-party Anthropic-compatible endpoint changes the backend brain while keeping the CLI interface. Before switching your daily workflow, keep three limitations in mind:
- Features requiring an Anthropic login are disabled: Claude Code Remote Control requires a claude.ai login and is disabled while
ANTHROPIC_BASE_URLpoints at a host other thanapi.anthropic.com, or whileANTHROPIC_AUTH_TOKENorANTHROPIC_API_KEYis in use. Cloud sessions are also not part of a custom-endpoint setup; Claude Code's docs say gateway variables set in a cloud session's environment are not applied. - Tool-calling and prompt behavior vary: Claude Code's system prompts, file-editing tools, and bash execution loops are tuned for Claude models. While DeepSeek, Kimi, GLM, Qwen, and MiniMax test their endpoints against Claude Code, complex multi-file edits, MCP servers, or image inputs may behave differently depending on the model.
- Billing is separate from your Claude plan: Requests sent to an external base URL are billed directly by that provider (via per-token API balance or the provider's own coding subscription plan) and never count against a Claude Pro or Max subscription.
Troubleshooting common errors
When a third-party endpoint fails in Claude Code, the cause is almost always a leftover credential, a mismatched regional URL, or an unmapped model tier.
| Symptom | Likely cause | Fix |
|---|---|---|
401 or 403 authentication error | Key belongs to a different platform/region (e.g., Z.ai vs BigModel, Moonshot .ai vs .cn, or Alibaba Singapore vs Beijing), or key type does not match the plan's base URL (e.g., a pay-as-you-go key on a Token Plan URL) | Verify the base URL matches the exact console and plan where you generated the key; check for trailing spaces |
/status shows wrong credential or Anthropic account | A saved claude.ai login or a leftover exported variable (ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN) is conflicting with your settings.json credential | Run /logout in Claude Code, run unset ANTHROPIC_API_KEY ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL, remove exports from ~/.zshrc, and restart |
"Model not found" or 400 on background tasks | Only ANTHROPIC_MODEL was set, leaving Haiku or subagent tiers sending default claude-* names to a provider that rejects them | Set all tier variables (ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL, and CLAUDE_CODE_SUBAGENT_MODEL; add ANTHROPIC_DEFAULT_FABLE_MODEL if your provider's guide sets it) |
400 error about unrecognized beta fields (Extra inputs are not permitted) | Upstream endpoint rejects experimental headers or request fields that Claude Code sends | Set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1, as Claude Code's gateway docs recommend |
To test your endpoint and API key outside of Claude Code, run a quick curl request against the provider's /v1/messages path. If curl returns a valid JSON message, your key and URL are working and any remaining issue is in your local environment variables.
Run Claude Code in the browser with AlwaysAgent
If you don't want to manage installs, shell profiles, or local config files across machines, AlwaysAgent gives each user a dedicated cloud Linux server with an independent public IP and both Claude Code and OpenAI Codex preinstalled.
- Bring your own model endpoint: Paste your Base URL and API key in the workspace settings—whether that is an official Anthropic or OpenAI key, DeepSeek, Kimi, GLM, Qwen, MiniMax, an API relay, or OpenRouter.
- Direct and private: Your API keys are saved only on your own server. AlwaysAgent never proxies your AI requests, adds a markup, or resells model quota.
- Work from any browser, 24/7: Use the web workspace (AI chat, file manager, terminal, remote browser preview, and version history) from your computer or phone browser without installing an app or configuring SSH. Because the server stays online 24/7, long tasks keep running after you close your laptop.
- Simple pricing once signups open: about $0.05/hour after a $10 top-up, or monthly plans from $9.9 (2 vCPU, 4 GB RAM, 40 GB disk).
Signups are paused while we onboard in batches. Join the waitlist and we’ll email you when a spot opens.
FAQ
Can I use DeepSeek, Kimi, GLM, Qwen, or MiniMax in Claude Code without a proxy?
Should I put my provider API key in ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY?
Why do I get a 401 error even though my API key is valid?
Why does Claude Code throw a "model not found" error partway through a task?
How can I switch between Claude, DeepSeek, and Kimi without editing settings.json every time?
Do non-Claude models work as well as Claude in Claude Code?
Skip the local setup
AlwaysAgent gives you a dedicated cloud Linux server with Claude Code and Codex preinstalled. Paste your Base URL and API key in settings and code from any browser.
Join the waitlist →