{"slug": "how-to-use-claude-code-with-deepseek-kimi-glm-qwen-and-minimax", "title": "How to use Claude Code with DeepSeek, Kimi, GLM, Qwen, and MiniMax", "summary": "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.", "body_md": "*Originally published at [alwaysagent.app](https://alwaysagent.app/claude-code-deepseek-kimi-glm). The original is kept up to date.*\n\nClaude 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.\n\nYou 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.\n\nClaude 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.\n\nThese 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.\n\nEvery 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.\n\n`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.\nPutting 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.\n\n`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.\nDeepSeek 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.\n\nCreate an API key in the DeepSeek Platform console, then add the configuration from DeepSeek's Claude Code guide to `~/.claude/settings.json`:\n\n**~/.claude/settings.json (DeepSeek)**\n\n```\n{\n  \"env\": {\n    \"ANTHROPIC_BASE_URL\": \"https://api.deepseek.com/anthropic\",\n    \"ANTHROPIC_AUTH_TOKEN\": \"YOUR_DEEPSEEK_API_KEY\",\n    \"ANTHROPIC_MODEL\": \"deepseek-flash[1m]\",\n    \"ANTHROPIC_DEFAULT_OPUS_MODEL\": \"deepseek-flash[1m]\",\n    \"ANTHROPIC_DEFAULT_SONNET_MODEL\": \"deepseek-flash[1m]\",\n    \"ANTHROPIC_DEFAULT_HAIKU_MODEL\": \"deepseek-flash\",\n    \"CLAUDE_CODE_SUBAGENT_MODEL\": \"deepseek-flash\",\n    \"CLAUDE_CODE_EFFORT_LEVEL\": \"max\",\n    \"CLAUDE_CODE_AUTO_COMPACT_WINDOW\": \"786432\"\n  }\n}\n```\n\n`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.\nMoonshot 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`.\n\nMoonshot'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:\n\n**~/.claude/settings.json (Kimi)**\n\n```\n{\n  \"env\": {\n    \"ANTHROPIC_BASE_URL\": \"https://api.moonshot.ai/anthropic\",\n    \"ANTHROPIC_AUTH_TOKEN\": \"YOUR_MOONSHOT_API_KEY\",\n    \"ANTHROPIC_MODEL\": \"kimi-k3[1m]\",\n    \"ANTHROPIC_DEFAULT_OPUS_MODEL\": \"kimi-k3[1m]\",\n    \"ANTHROPIC_DEFAULT_SONNET_MODEL\": \"kimi-k3[1m]\",\n    \"ANTHROPIC_DEFAULT_HAIKU_MODEL\": \"kimi-k3[1m]\",\n    \"ANTHROPIC_DEFAULT_FABLE_MODEL\": \"kimi-k3[1m]\",\n    \"CLAUDE_CODE_SUBAGENT_MODEL\": \"kimi-k3[1m]\",\n    \"CLAUDE_CODE_AUTO_COMPACT_WINDOW\": \"1000000\",\n    \"CLAUDE_CODE_EFFORT_LEVEL\": \"max\"\n  }\n}\n```\n\n`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.\nGLM 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.\n\nFor international users, register at Z.ai, create an API key, and point Claude Code at `https://api.z.ai/api/anthropic`:\n\n**~/.claude/settings.json (GLM via Z.ai)**\n\n```\n{\n  \"env\": {\n    \"ANTHROPIC_BASE_URL\": \"https://api.z.ai/api/anthropic\",\n    \"ANTHROPIC_AUTH_TOKEN\": \"YOUR_ZAI_API_KEY\",\n    \"API_TIMEOUT_MS\": \"3000000\",\n    \"ANTHROPIC_DEFAULT_OPUS_MODEL\": \"GLM-5.3-Flash\",\n    \"ANTHROPIC_DEFAULT_SONNET_MODEL\": \"GLM-5.3-Flash\",\n    \"ANTHROPIC_DEFAULT_HAIKU_MODEL\": \"GLM-5.3-Flash\"\n  }\n}\n```\n\n`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]`).\nAlibaba 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.\n\nFor international accounts (Singapore, `ap-southeast-1`), Alibaba Cloud Model Studio's Claude Code guide documents the following Token Plan configuration:\n\n**~/.claude/settings.json (Qwen International Token Plan)**\n\n```\n{\n  \"env\": {\n    \"ANTHROPIC_BASE_URL\": \"https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic\",\n    \"ANTHROPIC_AUTH_TOKEN\": \"YOUR_MODEL_STUDIO_API_KEY\",\n    \"ANTHROPIC_MODEL\": \"auto\",\n    \"ANTHROPIC_DEFAULT_HAIKU_MODEL\": \"qwen3.6-flash\",\n    \"ANTHROPIC_DEFAULT_SONNET_MODEL\": \"qwen3.8-flash\",\n    \"ANTHROPIC_DEFAULT_OPUS_MODEL\": \"qwen4-max-preview\",\n    \"CLAUDE_CODE_SUBAGENT_MODEL\": \"auto\",\n    \"CLAUDE_CODE_MAX_CONTEXT_TOKENS\": \"983616\"\n  }\n}\n```\n\nIf 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:\n\n**~/.claude/settings.json (Qwen Workspace Pay-as-you-go)**\n\n```\n{\n  \"env\": {\n    \"ANTHROPIC_BASE_URL\": \"https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic\",\n    \"ANTHROPIC_AUTH_TOKEN\": \"YOUR_DASHSCOPE_API_KEY\",\n    \"ANTHROPIC_MODEL\": \"qwen3.7-max\",\n    \"ANTHROPIC_DEFAULT_HAIKU_MODEL\": \"qwen3.6-flash\",\n    \"ANTHROPIC_DEFAULT_SONNET_MODEL\": \"qwen3.7-max\",\n    \"ANTHROPIC_DEFAULT_OPUS_MODEL\": \"qwen3.7-max\",\n    \"CLAUDE_CODE_SUBAGENT_MODEL\": \"qwen3.7-max\"\n  }\n}\n```\n\n`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.\nMiniMax 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`).\n\nBefore 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:\n\n**~/.claude/settings.json (MiniMax)**\n\n```\n{\n  \"env\": {\n    \"ANTHROPIC_BASE_URL\": \"https://api.minimax.io/anthropic\",\n    \"ANTHROPIC_AUTH_TOKEN\": \"YOUR_MINIMAX_API_KEY\",\n    \"CLAUDE_CODE_AUTO_COMPACT_WINDOW\": \"524288\",\n    \"CLAUDE_CODE_EFFORT_LEVEL\": \"max\",\n    \"ANTHROPIC_MODEL\": \"MiniMax-M3.1-Flash[1m]\",\n    \"ANTHROPIC_DEFAULT_SONNET_MODEL\": \"MiniMax-M3.1-Flash[1m]\",\n    \"ANTHROPIC_DEFAULT_OPUS_MODEL\": \"MiniMax-M3.1-Flash[1m]\",\n    \"ANTHROPIC_DEFAULT_HAIKU_MODEL\": \"MiniMax-M3.1-Flash[1m]\"\n  }\n}\n```\n\n`https://api.minimax.io/anthropic`. MiniMax's China-site guide (` platform.minimax.cn`) uses `https://api.minimax.cn/anthropic` with the same model names.\nUse 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.\n\n`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.\n| Provider | International ANTHROPIC_BASE_URL | Mainland China Endpoint | Official Guide | \n|---|---|---|---|\n| DeepSeek | [https://api.deepseek.com/anthropic](https://api.deepseek.com/anthropic) | Same endpoint | [DeepSeek Docs](https://api-docs.deepseek.com/guides/anthropic_api) | \n| 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) | \n| 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) | \n| 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) | \n| 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) | \n\nEditing `~/.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.\n\nAccording to Claude Code's settings precedence rules, command-line `claude --settings` overrides user settings (`~/.claude/settings.json`) and project settings for that session.\n\n`~/.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`\n**~/.zshrc or ~/.bashrc**\n\n```\nalias claude-ds=\"claude --settings ~/.claude/deepseek.json\"\nalias claude-kimi=\"claude --settings ~/.claude/kimi.json\"\nalias claude-glm=\"claude --settings ~/.claude/glm.json\"\nalias claude-minimax=\"claude --settings ~/.claude/minimax.json\"\n```\n\nTo 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.\n\nPointing 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:\n\n`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.\n\n| Symptom | Likely cause | Fix | \n|---|---|---|\n| 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 | \n| /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 | \n| \"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) | \n| 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 | \n\nTo 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.\n\nIf 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.\n\nSignups are paused while we onboard in batches. [Join the waitlist](https://dev.to/#waitlist) and we’ll email you when a spot opens.\n\nYes. 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.\n\nUse 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.\n\nThe 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.\n\nClaude 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.\n\nSave 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.\n\nIt 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.", "url": "https://wpnews.pro/news/how-to-use-claude-code-with-deepseek-kimi-glm-qwen-and-minimax", "canonical_source": "https://dev.to/alwaysagent/how-to-use-claude-code-with-deepseek-kimi-glm-qwen-and-minimax-1j67", "published_at": "2026-11-29 02:10:07+00:00", "updated_at": "2026-11-29 02:13:45.139899+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "developer-tools", "large-language-models"], "entities": ["Anthropic", "Claude Code", "DeepSeek", "Moonshot", "Kimi", "Z.ai", "GLM", "Qwen"], "also_reported_by": [], "takeaway": "Claude Code can be routed to DeepSeek, Kimi, GLM, Qwen, or MiniMax by setting ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and the model-tier mappings in settings.json, with no proxy needed since those providers natively serve Anthropic's Messages API.", "recommendation": {"advice": "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.", "playbook": "llm-cost", "playbook_url": "https://wpnews.pro/playbooks/llm-cost"}, "alternates": {"html": "https://wpnews.pro/news/how-to-use-claude-code-with-deepseek-kimi-glm-qwen-and-minimax", "markdown": "https://wpnews.pro/news/how-to-use-claude-code-with-deepseek-kimi-glm-qwen-and-minimax.md", "text": "https://wpnews.pro/news/how-to-use-claude-code-with-deepseek-kimi-glm-qwen-and-minimax.txt", "jsonld": "https://wpnews.pro/news/how-to-use-claude-code-with-deepseek-kimi-glm-qwen-and-minimax.jsonld"}}