How to use Claude Code with DeepSeek, Kimi, GLM, Qwen, and MiniMax A developer guide shows how to point Claude Code, Anthropic's terminal coding agent, at third-party models from DeepSeek, Moonshot (Kimi), Z.ai (GLM), Alibaba Cloud Model Studio (Qwen), and MiniMax by setting Anthropic-compatible base URLs, auth tokens, and model mappings in environment variables or the settings.json env block. The approach requires no third-party proxy or CLI modification because all five providers publish endpoints that natively speak Anthropic's Messages API format. The guide cautions that Anthropic does not support or guarantee Claude Code when routed to non-Claude models and recommends testing each provider on a small task before production use. Originally published at alwaysagent.app https://alwaysagent.app/claude-code-deepseek-kimi-glm . The original is kept up to date. Claude Code is a terminal coding agent, not a single locked-in model. Because DeepSeek, Moonshot Kimi , Z.ai GLM , Alibaba Cloud Model Studio Qwen , and MiniMax all publish official Anthropic-compatible endpoints, you can connect Claude Code to any of them with a base URL, an API key, and a model mapping. 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. 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 of https://api.anthropic.com . ANTHROPIC AUTH TOKEN : Holds your provider API key. Claude Code sends this value as an Authorization: Bearer header. ANTHROPIC MODEL : Sets the primary active model for your session. ANTHROPIC DEFAULT OPUS MODEL , ANTHROPIC DEFAULT SONNET MODEL , and ANTHROPIC 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 the fable alias. 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. ANTHROPIC API KEY : x-api-key header. /logout inside Claude Code so your token and base URL take over cleanly. ~/.claude/settings.json user scope or .claude/settings.local.json git-ignored project scope . Never put API keys in a shared project .claude/settings.json file that gets committed to version control. env block, Claude Code applies the settings file value in most sessions. Providers such as MiniMax and Moonshot still recommend clearing old export ANTHROPIC lines from ~/.zshrc or ~/.bashrc first, because stale values can conflict with the new 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 : ~/.claude/settings.json DeepSeek { "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" } } deepseek-flash and deepseek-v4-pro . claude- model name reaches its endpoint, names starting with claude-opus are automatically mapped to claude-sonnet or claude-haiku names are mapped to 400 error. 1m tells Claude Code to treat the model as having a 1M context window rather than capping sessions at 200k. 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: ~/.claude/settings.json Kimi { "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" } } kimi-k3 1m for every tier. Kimi K3 always reasons, so no separate thinking parameter is needed; control reasoning effort with CLAUDE CODE EFFORT LEVEL . platform.kimi.com uses https://api.moonshot.cn/anthropic . The base URL must match the platform where your key was created. 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 : ~/.claude/settings.json GLM via Z.ai { "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" } } https://api.z.ai/api/anthropic with a Z.ai account. If your account and API key were created on Zhipu's mainland China platform open.bigmodel.cn , use https://open.bigmodel.cn/api/anthropic instead, as shown in Zhipu's own Claude Code guide. npx @z ai/coding-helper that helps set up Claude Code for the GLM Coding Plan. GLM-5.3-Flash or glm-5.3 1m . 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: ~/.claude/settings.json Qwen International Token Plan { "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: ~/.claude/settings.json Qwen Workspace Pay-as-you-go { "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" } } 401 invalid api key error. For mainland China, Alibaba's China-site guide uses the cn-beijing region for example https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic and https://coding.dashscope.aliyuncs.com/apps/anthropic for Coding Plan keys. The international Coding Plan URL is https://coding-intl.dashscope.aliyuncs.com/apps/anthropic . 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 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: ~/.claude/settings.json MiniMax { "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 " } } https://api.minimax.io/anthropic . MiniMax's China-site guide platform.minimax.cn uses https://api.minimax.cn/anthropic with the same model names. 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/anthropic : Supports deepseek-flash and deepseek-v4-pro, plus automatic claude- alias fallback. https://api.moonshot.ai/anthropic : Supports Kimi K3 with 1M context window support. https://...maas.aliyuncs.com/apps/anthropic : Regional and plan-specific endpoints for Qwen models on Alibaba Cloud Model Studio. | Provider | International ANTHROPIC BASE URL | Mainland China Endpoint | Official Guide | |---|---|---|---| | DeepSeek | https://api.deepseek.com/anthropic https://api.deepseek.com/anthropic | Same endpoint | DeepSeek Docs https://api-docs.deepseek.com/guides/anthropic api | | Kimi Moonshot | https://api.moonshot.ai/anthropic https://api.moonshot.ai/anthropic | https://api.moonshot.cn/anthropic https://api.moonshot.cn/anthropic | Kimi Docs https://platform.kimi.ai/docs/guide/claude-code-kimi | | GLM Z.ai / Zhipu | https://api.z.ai/api/anthropic https://api.z.ai/api/anthropic | https://open.bigmodel.cn/api/anthropic https://open.bigmodel.cn/api/anthropic | Z.ai Docs https://docs.z.ai/devpack/tool/claude | | 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 https://www.alibabacloud.com/help/en/model-studio/claude-code | | MiniMax | https://api.minimax.io/anthropic https://api.minimax.io/anthropic | https://api.minimax.cn/anthropic https://api.minimax.cn/anthropic | MiniMax Docs https://platform.minimax.io/docs/token-plan/claude-code | 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. ~/.claude/deepseek.json , ~/.claude/kimi.json , ~/.claude/glm.json , and so on. Restrict permissions with chmod 600 ~/.claude/ .json so other local users cannot read your keys. claude --settings . /status ~/.zshrc or ~/.bashrc 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. 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: api.anthropic.com , or while 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. If you don't want to manage installs, shell profiles, or local config files across machines, AlwaysAgent https://alwaysagent.app gives each user a dedicated cloud Linux server with an independent public IP and both Claude Code and OpenAI Codex preinstalled. Signups are paused while we onboard in batches. Join the waitlist https://dev.to/ waitlist and we’ll email you when a spot opens. Yes. All five providers operate official Anthropic-compatible API endpoints. You only need to set ANTHROPIC BASE URL to the provider's Anthropic endpoint and ANTHROPIC AUTH TOKEN to your provider API key, plus map the model names in ~/.claude/settings.json. Use ANTHROPIC AUTH TOKEN. Claude Code sends ANTHROPIC AUTH TOKEN as an Authorization: Bearer header, which is what DeepSeek, Kimi, Z.ai, Alibaba Cloud Model Studio, and MiniMax document in their Claude Code guides. Unset ANTHROPIC API KEY or set it to an empty string so it does not conflict. The two most common causes are a leftover credential in your shell such as an exported ANTHROPIC API KEY or a cached claude.ai login or a regional endpoint mismatch. For example, Z.ai and Zhipu mainland accounts use different base URLs api.z.ai vs open.bigmodel.cn , Moonshot uses api.moonshot.ai vs api.moonshot.cn, and each Alibaba Cloud Model Studio plan needs its own key with its matching base URL. Run /logout, unset conflicting shell variables, and verify the base URL. Claude Code uses different model tiers Opus, Sonnet, Haiku, and subagent for different tasks such as background file indexing or subagents. If you only set ANTHROPIC MODEL, background calls still send default claude- model names. Map ANTHROPIC DEFAULT OPUS MODEL, ANTHROPIC DEFAULT SONNET MODEL, ANTHROPIC DEFAULT HAIKU MODEL, and CLAUDE CODE SUBAGENT MODEL to valid model IDs on your provider. Save each provider's configuration in its own file for example, ~/.claude/deepseek.json and ~/.claude/kimi.json and launch Claude Code with claude --settings ~/.claude/deepseek.json. You can bind each command to a short shell alias. It depends on the model and task. Claude Code's prompts and tool definitions are designed for Anthropic's Claude models, and Anthropic does not officially support non-Claude models behind custom base URLs. Always test your chosen model on small coding tasks and check how it handles multi-file edits and tool calls before using it on critical repositories.