# How to use Claude Code with DeepSeek, Kimi, GLM, Qwen, and MiniMax

> 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.

Source: https://alwaysagent.app/claude-code-deepseek-kimi-glm
Updated: 2026-11-15

## 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 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.

- **Use `ANTHROPIC_AUTH_TOKEN`, not `ANTHROPIC_API_KEY`:** Provider guides use `ANTHROPIC_AUTH_TOKEN`. Leaving an old `ANTHROPIC_API_KEY` exported in your shell causes authentication conflicts because Claude Code sends it as an `x-api-key` header.
- **Clear saved logins:** If you previously signed in with a claude.ai subscription, run `/logout` inside 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.json` file that gets committed to version control.
- **Mind variable precedence:** When the same variable is set in both your shell and a settings file `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 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"
  }
}
```

- **Available models:** DeepSeek's Anthropic endpoint supports `deepseek-flash` and `deepseek-v4-pro`.
- **Built-in alias fallback:** DeepSeek notes that if an unmapped `claude-*` model name reaches its endpoint, names starting with `claude-opus` are automatically mapped to `deepseek-v4-pro`, and `claude-sonnet` or `claude-haiku` names are mapped to `deepseek-flash`. Non-Claude model names that DeepSeek does not recognize return a `400` error.
- **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:

`~/.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"
  }
}
```

- **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 with `CLAUDE_CODE_EFFORT_LEVEL`.
- **China mainland:** Moonshot's China-site guide (`platform.kimi.com`) uses `https://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`:

`~/.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"
  }
}
```

- **International vs. China mainland endpoints:** Use `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.
- **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-Flash` or `glm-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:

`~/.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"
  }
}
```

- **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_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`.
- **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:

`~/.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]"
  }
}
```

- **China mainland endpoint:** International accounts use `https://api.minimax.io/anthropic`. MiniMax's China-site guide (`platform.minimax.cn`) uses `https://api.minimax.cn/anthropic` with 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.

- **DeepSeek** (`https://api.deepseek.com/anthropic`): Supports deepseek-flash and deepseek-v4-pro, plus automatic claude-* alias fallback.
- **Kimi (Moonshot)** (`https://api.moonshot.ai/anthropic`): Supports Kimi K3 with 1M context window support.
- **GLM (Z.ai)** (`https://api.z.ai/api/anthropic`): International endpoint for GLM Coding Plan and API keys (mainland China uses open.bigmodel.cn).
- **Qwen (Model Studio)** (`https://...maas.aliyuncs.com/apps/anthropic`): Regional and plan-specific endpoints for Qwen models on Alibaba Cloud Model Studio.
- **MiniMax** (`https://api.minimax.io/anthropic`): Supports 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](https://api-docs.deepseek.com/guides/anthropic_api) |
| Kimi (Moonshot) | https://api.moonshot.ai/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://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.cn/anthropic | [MiniMax Docs](https://platform.minimax.io/docs/token-plan/claude-code) |

## 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.

1. **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 with `chmod 600 ~/.claude/*.json` so other local users cannot read your keys.
1. **Add shell aliases** — Add short aliases to your `~/.zshrc` or `~/.bashrc` file that pass the matching file to `claude --settings`.
1. **Verify with `/status`** — When you start a session with one of your aliases, run `/status` to confirm the expected base URL and model are active.

`~/.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.

## 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_URL` points at a host other than `api.anthropic.com`, or while `ANTHROPIC_AUTH_TOKEN` or `ANTHROPIC_API_KEY` is 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](https://alwaysagent.app) 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](/#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?

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.

### Should I put my provider API key in ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY?

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.

### Why do I get a 401 error even though my API key is valid?

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.

### Why does Claude Code throw a "model not found" error partway through a task?

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.

### How can I switch between Claude, DeepSeek, and Kimi without editing settings.json every time?

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.

### Do non-Claude models work as well as Claude in Claude Code?

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.
