cd /news/ai-tools/how-to-use-claude-code-with-deepseek… · home › topics › ai-tools › article
[ARTICLE · art-177947] src=dev.to ↗ pub= topic=ai-tools verified=true sentiment=· neutral

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.

recommendation

To cut API spend, map Claude Code's Opus, Sonnet, and Haiku tiers to cheaper provider model IDs via settings.json env vars, but test each provider on a small task first since Anthropic does not guarantee non-Claude routing.

more in playbook: Controlling LLM cost
by read10 min views16 publishedNov 29, 2026

Originally published at alwaysagent.app. 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 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

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 gives each user a dedicated cloud Linux server with an independent public IP and both Claude Code and OpenAI Codex preinstalled.

Signups are d while we onboard in batches. Join the 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.

── more in #ai-tools 4 stories · sorted by recency
── more on @anthropic 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-to-use-claude-co…] indexed:0 read:10min 2026-11-29 · —