How to Use DeepSeek with Claude Code (Kimi, GLM & Qwen Alternatives)

Quick answer
Yes. If you like Claude Code but dislike the cost of running Claude models for every coding task, you do not necessarily need to replace Claude Code itself.
Claude Code is the agent harness: it reads your repository, edits files, runs shell commands, calls tools, follows CLAUDE.md, uses subagents, and manages the coding workflow. Claude Sonnet or Opus is the model behind that workflow.
Claude Code = agent harness / CLI workflowClaude Sonnet / Opus = model
You can keep the harness and replace the model.DeepSeek now officially documents a direct Claude Code integration through its Anthropic-compatible API. That makes Claude Code + DeepSeek one of the easiest lower-cost setups to try today.
Kimi, GLM and Qwen can also be useful alternatives, but the integration path depends on the provider. Some expose Anthropic-compatible APIs directly; others may require a gateway or translation layer such as LiteLLM or OpenRouter.
The practical strategy is usually not “replace Claude forever.” It is:
routine coding / tests / repetitive work → lower-cost modelhard planning / architecture / final review → ClaudeThat gives you most of the Claude Code experience without paying premium-model prices for every token.
Claude Code is not the same thing as the Claude model
This distinction matters because a lot of “Claude Code alternatives” discussions mix up two separate layers.
Claude Code gives you the agentic developer experience:
- terminal-first workflow
- repository context
- multi-file edits
- bash/tool execution
CLAUDE.md- planning
- subagents
- autonomous task loops
- code review and iteration
The model is the “brain” that decides what to do inside that harness.
So if your complaint is:
“I like Claude Code, but long agent sessions are too expensive.”
the first thing to try is not necessarily OpenCode, Codex, Cursor, or another coding agent.
Try replacing the model first.
Why developers look for cheaper models inside Claude Code
Long agentic sessions can consume a surprising number of tokens. The cost grows especially fast when you combine:
- large repositories
- repeated file reads
- long debugging sessions
- tool calls
- test/fix/retest loops
- subagents
- planning plus implementation plus review
- autonomous sessions that run for a long time
A cheaper model changes the economics of using an agent.
Instead of asking:
“Can I afford to let Claude keep working on this?”
you can use a low-cost model for high-volume tasks and reserve Claude for the places where its stronger agent reliability is worth paying for.
This is also why token price alone is not the right metric.
The better metric is:
cost per successfully completed coding task
A cheap model that loops, makes bad edits, and retries ten times can lose much of its headline price advantage. A more expensive model that solves the task cleanly in one pass may still be economical.
How to run Claude Code with DeepSeek V4
DeepSeek is currently the cleanest example because its official documentation includes a dedicated Claude Code integration.

DeepSeek exposes an Anthropic-compatible endpoint at:
https://api.deepseek.com/anthropicThat means Claude Code can keep sending Anthropic-style requests while DeepSeek serves the underlying model.
macOS / Linux setup
If Claude Code is already installed, configure these environment variables:
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"export ANTHROPIC_AUTH_TOKEN="<your DeepSeek API key>"
export ANTHROPIC_MODEL="deepseek-v4-pro[1m]"export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro[1m]"export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"export CLAUDE_CODE_EFFORT_LEVEL="max"export CLAUDE_CODE_AUTO_COMPACT_WINDOW="786432"Then enter your project:
cd /path/to/your/projectclaudeThat is a real, officially documented DeepSeek configuration rather than a generic proxy example.
Windows PowerShell setup
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"$env:ANTHROPIC_AUTH_TOKEN="<your DeepSeek API key>"
$env:ANTHROPIC_MODEL="deepseek-v4-pro[1m]"$env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro[1m]"$env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"$env:CLAUDE_CODE_EFFORT_LEVEL="max"$env:CLAUDE_CODE_AUTO_COMPACT_WINDOW="786432"Then:
cd C:\path\to\your\projectclaudeModel names, environment variables and pricing can change quickly. The configuration above reflects DeepSeek’s official Claude Code documentation checked on September 9, 2026. Verify the provider docs again if you are reading this much later.
How DeepSeek maps Claude Code models
This is more important than it may look.
Claude Code often thinks in terms of Anthropic model roles such as Opus, Sonnet and Haiku. DeepSeek’s Anthropic-compatible API can translate those model names to DeepSeek models.
DeepSeek currently documents this mapping:
claude-opus-* → deepseek-v4-proclaude-sonnet-* / haiku-* → deepseek-v4-flashThe explicit environment-variable setup above can override that default behavior.
A practical configuration is:
main model / hard work → DeepSeek V4 ProOpus role → DeepSeek V4 ProSonnet role → DeepSeek V4 ProHaiku role → DeepSeek V4 Flashsubagents → DeepSeek V4 FlashThis matters for cost because subagents can generate a lot of traffic. Putting high-volume subagent work on Flash while keeping Pro for the main task is a more useful optimization than simply saying “use a cheap model.”
Persistent shell configuration
If you want the DeepSeek setup to survive new terminal sessions, put the variables in your shell profile.
For zsh:
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"export ANTHROPIC_AUTH_TOKEN="<your DeepSeek API key>"export ANTHROPIC_MODEL="deepseek-v4-pro[1m]"export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro[1m]"export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"Reload the shell:
source ~/.zshrcIf you regularly switch between Anthropic and DeepSeek, I prefer shell aliases or small launcher scripts instead of permanently changing every Claude Code session.
For example:
#!/usr/bin/env bash
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"export ANTHROPIC_AUTH_TOKEN="$DEEPSEEK_API_KEY"export ANTHROPIC_MODEL="deepseek-v4-pro[1m]"export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
exec claude "$@"That keeps your default Claude Code environment separate.
What an Anthropic-compatible endpoint actually does
Without a compatibility layer, the architecture is roughly:
Claude Code ↓Anthropic Messages API ↓ClaudeWith a compatible provider:
Claude Code ↓Anthropic-compatible API ↓DeepSeek / another modelIf a model provider does not expose the Anthropic Messages API directly, the path may instead look like:
Claude Code ↓LiteLLM / gateway / router ↓provider-native API ↓Kimi / GLM / Qwen / another modelThe proxy translates the request and response formats.
But there is an important warning:
Anthropic-compatible does not mean behaviorally identical to Claude.
An API can accept the same request structure while differing in:
- tool calling
- streaming
- reasoning fields
- system prompt handling
- cache semantics
- context handling
- model-name mapping
- long-horizon agent behavior
That is why a backend can “work with Claude Code” while still feeling noticeably different from Claude.
Can Claude Code use Kimi, GLM or Qwen?
Potentially yes, but I would not treat all providers as equally plug-and-play.
DeepSeek is easy to recommend because there is a current official Claude Code integration page.
For Kimi, GLM and Qwen, verify the exact provider you plan to use:
- Does it expose an Anthropic-compatible Messages API?
- Does it support tool calling correctly?
- Does it handle streaming and tool results in the way Claude Code expects?
- Can it map Claude model names?
- If not, does your gateway translate Anthropic requests reliably?
A practical way to think about the options is:
| Model family | Claude Code path | Why consider it | What to verify |
|---|---|---|---|
| DeepSeek | Official Anthropic-compatible integration | Very low cost, V4 Pro/Flash routing, official Claude Code docs | Current model names and pricing |
| Kimi | Provider-dependent direct endpoint or gateway | Long-context ecosystem, competitive coding models | Anthropic compatibility and tool calls |
| GLM | Provider-dependent direct endpoint or gateway | Low-cost option, convenient for many China-based developers | Endpoint behavior and model mapping |
| Qwen | Provider/gateway dependent | Strong coding ecosystem and many deployment options | Claude Code compatibility layer |
| Claude | Native | Highest compatibility with Claude Code | Higher cost |
The key is not whether a model is “Chinese” or “Western.” It is whether the full model + API compatibility + agent loop works reliably enough for your tasks.
DeepSeek vs Kimi vs GLM vs Qwen for Claude Code
I would avoid pretending there is one universal ranking. Coding-agent quality depends heavily on:
- repository size
- programming language
- task duration
- tool-use complexity
- how much planning is needed
- tolerance for retries
- provider implementation
A more useful comparison is:
| Model family | Main reason to try it | Best starting use |
|---|---|---|
| DeepSeek | Official Claude Code integration plus aggressive API pricing | Routine coding, backend work, tests, debugging, subagents |
| Kimi | Long-context ecosystem and strong general/coding models | Large-context work, mixed coding/documentation |
| GLM | Affordable general-purpose alternative | Everyday development and debugging |
| Qwen | Broad coding/open-model ecosystem | Code generation, structured tasks, self-hosted/provider-specific setups |
| Claude Sonnet/Opus | Native Claude Code behavior and stronger hard-task reliability | Complex planning, architecture, difficult refactors, final review |
I would start with DeepSeek if the main goal is simply:
“I want Claude Code, but cheaper.”
The official integration removes a lot of uncertainty.
Claude vs DeepSeek API cost
This is where the “cheaper alternative” claim becomes concrete.
Prices below were checked against the official provider pages on September 9, 2026 and are shown per 1 million tokens. Providers can change them at any time.
DeepSeek V4 pricing
DeepSeek currently uses peak and off-peak pricing.
| Model | Input cache miss | Output |
|---|---|---|
| DeepSeek V4 Flash — off-peak | $0.22 | $0.66 |
| DeepSeek V4 Flash — peak | $0.44 | $1.32 |
| DeepSeek V4 Pro — off-peak | $0.66 | $1.98 |
| DeepSeek V4 Pro — peak | $1.32 | $3.96 |
DeepSeek also prices cache hits much lower than cache misses.
Claude API pricing
For reference, Anthropic’s current standard API pricing includes:
| Model | Input | Output |
|---|---|---|
| Claude Sonnet 5 | $2.00 | $10.00 |
| Claude Opus 5 | $5.00 | $25.00 |
This makes the raw token-price difference substantial.
But I would still avoid turning that into a blanket claim such as:
“DeepSeek is always 10x cheaper.”
That ignores retries, tool loops, caching and task success rate.
Do not compare only $/million tokens
Imagine two hypothetical coding sessions:
Model A$0.50 per attempt × 1 successful attempt = $0.50
Model B$0.08 per attempt × 10 attempts/retries = $0.80Model B has a dramatically lower token price but costs more to finish the task.
So the metric that matters is:
cost per successfully completed task
For agentic coding, this is often more useful than benchmark scores or API price alone.
The best strategy is usually hybrid, not full replacement

The strongest cost-saving setup is often not:
Claude everywhereand not:
cheap model everywhereIt is model escalation.
For example:
Plan → ClaudeImplement → DeepSeek V4 ProSubagents → DeepSeek V4 FlashTests → DeepSeek V4 Flash / ProFinal review → ClaudeOr a simpler workflow:
Routine task? ↓Try DeepSeek ↓Working well? ── Yes → keep going ↓ NoEscalate to ClaudeAn “80% cheap model + 20% Claude” split is a useful mental model, but treat it as a workflow heuristic, not a benchmark result.
A practical cost-saving workflow
Step 1 — Start routine work on the cheaper model
Good candidates include:
- CRUD code
- boilerplate
- test generation
- documentation
- scripts
- small bug fixes
- straightforward refactors
- repetitive subagent work
Step 2 — Watch for failure signals
Escalate when you see:
- repeated failed edits
- the agent editing unrelated files
- tool-call failures
- circular reasoning
- repeated test failures without progress
- architecture confusion
- lost requirements
- an agent claiming success without actually fixing the problem
Step 3 — Use Claude where judgment matters
Good escalation tasks include:
- architecture planning
- hard debugging
- ambiguous requirements
- repository-wide refactors
- concurrency/security-sensitive changes
- final review
This creates a useful division of labor:
lower-cost model → high-volume implementationClaude → difficult reasoning and reviewWhere cheaper models can still fall behind Claude
A low token price does not automatically make a model a better coding agent.
Long-horizon agent behavior
The harder the task becomes, the more important it is for the model to remember the original objective across many tool calls and edits.
Common failure modes include:
- forgetting earlier constraints
- making locally correct but globally inconsistent changes
- repeating the same action
- losing track of which files have already changed
- stopping too early
Tool-calling edge cases
Claude Code relies heavily on structured tool use.
Compatibility problems may show up as:
- malformed tool arguments
- incorrect
tool_resulthandling - streaming differences
- proxy translation bugs
- reasoning-field incompatibility
Large-repository reasoning
A task like:
“Understand this large repository, identify the architectural boundary, redesign subsystem X and migrate callers safely.”
is very different from:
“Add one API endpoint and tests.”
Cheap models can be excellent for the second task while still being less reliable for the first.
Agent loops can erase the price advantage
This is worth repeating because it is easy to miss.
If a cheaper model keeps looping, token consumption grows rapidly. The cheapest model on the pricing page may not be the cheapest model for your actual work.
Common Claude Code compatibility problems
Authentication errors
Check the non-secret variables:
echo "$ANTHROPIC_BASE_URL"echo "$ANTHROPIC_MODEL"Do not paste real API keys into bug reports, screenshots or public logs.
Model not found
Use the model identifier expected by your provider.
With DeepSeek, the official Claude Code integration currently documents names such as:
deepseek-v4-pro[1m]deepseek-v4-flashProvider model names change faster than Claude Code itself, so check the current docs.
Tool calls fail
Possible causes include:
- provider incompatibility
- model limitations
- an API gateway bug
- unsupported tool schema behavior
- streaming translation problems
If normal chat works but Claude Code tool use breaks, test the compatibility layer before blaming Claude Code.
Reasoning/thinking errors
Some models expose extra reasoning fields that do not map cleanly onto every Anthropic-compatible implementation.
A translation layer may need explicit support for those fields.
The agent keeps looping
Try, in order:
- make the task smaller
- restart with a clean context
- reduce autonomy
- ask a stronger model to create the plan
- switch the implementation back to the cheap model
- escalate the whole task to Claude if necessary
What about project-specific model configuration?
There are good reasons to avoid using one backend globally.
For example:
work repository → Claudepersonal side project → DeepSeeklarge cheap subagents → DeepSeek Flashhigh-risk review → ClaudeClaude Code supports project and local configuration under .claude/, but its configuration surface changes over time.
I would not copy an unverified settings.local.json field from an old blog post. Check the current Claude Code settings documentation before storing provider-specific environment variables or model settings there.
For many developers, a small shell launcher is simpler and easier to audit.
What Reddit and X developers actually care about
Community discussions about cheaper Claude Code backends repeatedly circle around a few practical questions.
These are patterns from developer discussions, not controlled benchmark results.
| Question | Practical answer |
|---|---|
| Is a cheaper model good enough for daily coding? | Often, yes |
| Does it replace Claude for every agentic task? | No |
| What saves the most money? | Routing routine work to cheap models and escalating hard work |
| What can ruin the savings? | Failed tool calls, loops and repeated retries |
| Does benchmark rank tell the whole story? | No — API compatibility and agent behavior matter |
| Why keep Claude Code? | The harness itself is a major part of the value |
A recurring sentiment can be summarized as:
Use the cheap model while it is working. Switch back to Claude when the task gets hard.
That is more realistic than treating every model release as a permanent “Claude killer.”
What about Claude Code in mainland China?
For developers in mainland China, domestic model providers can have practical advantages beyond price:
- easier direct API access
- RMB payment
- lower network latency
- less dependence on an Anthropic account
- local billing/support options
That makes the “keep Claude Code, change the backend” approach especially interesting.
I would avoid anonymous relay services, account resale, stolen API keys, subscription sharing or other gray-market workarounds.
Prefer:
- the model provider’s official API
- a reputable gateway
- a self-hosted compatibility layer you control
The cheaper option is not worth it if the provider can inspect your private repository or disappear with your API balance.
Should you replace Claude Code entirely?
Not necessarily.
There are two different decisions:
Decision A: Which agent harness do I want?
Examples:
- Claude Code
- OpenCode
- Codex
- other coding agents
Decision B: Which model should power the workflow?
Examples:
- Claude
- DeepSeek
- Kimi
- GLM
- Qwen
If your answer to Decision A is already:
“I like Claude Code.”
then solve Decision B first.
| Setup | Keep Claude Code? | Main reason |
|---|---|---|
| Claude Code + Claude | Yes | Native behavior and highest compatibility |
| Claude Code + DeepSeek | Yes | Official low-cost alternative backend |
| Claude Code + Kimi | Yes | Alternative model if provider/gateway compatibility is good |
| Claude Code + GLM | Yes | Low-cost alternative |
| Claude Code + Qwen | Yes | Flexible coding/model ecosystem |
| OpenCode | No | More model/harness flexibility |
| Codex | No | OpenAI-native agent workflow |
Is DeepSeek a real Claude Code replacement?
This question mixes two categories.
DeepSeek is a model. Claude Code is an agent harness.
The useful comparison is:
Claude Code + DeepSeekvs.Claude Code + Claude Sonnet / OpusFor routine coding, tests, debugging and repetitive work, DeepSeek can replace the underlying Claude model for a substantial portion of a developer’s workflow.
For complex planning, difficult repository reasoning, high-risk refactors and final review, keeping Claude as an escalation path is usually safer.
My recommended setup
If your main reason for searching for a Claude Code alternative is cost, I would start with this:
Lowest-cost starting point
Claude Code+DeepSeek V4 Flash / ProUse Flash aggressively for high-volume work and subagents.
Best balance
Plan / hard reasoning → ClaudeImplementation → DeepSeek V4 ProSubagents / tests → DeepSeek V4 FlashReview → ClaudeMaximum reliability
Claude Code+Claude Sonnet / OpusYou pay more, but you remove most API compatibility uncertainty.
Decision tree
Do you already like Claude Code? | Yes |Is model/API cost the main problem? | Yes |Start with DeepSeek's official Claude Code integration | +-- Routine coding/tests/subagents → DeepSeek Flash or Pro | +-- Hard task still succeeds? → stay on DeepSeek | +-- Repeated failures/loops? → escalate to Claude |Want to test another Chinese model? | +-- Kimi / GLM / Qwen |Verify Anthropic API + tool-call compatibility firstFAQ
Can Claude Code use DeepSeek?
Yes. DeepSeek currently provides an official Anthropic-compatible Claude Code integration. Set ANTHROPIC_BASE_URL to DeepSeek’s Anthropic endpoint, provide your DeepSeek API key, select a supported model, and run claude.
What is the DeepSeek Claude Code API endpoint?
DeepSeek currently documents:
https://api.deepseek.com/anthropicVerify the official DeepSeek documentation if you are reading this article later, because API endpoints can change.
Can Claude Code use Kimi?
It can if the Kimi provider you use exposes a sufficiently compatible Anthropic API, or if you use a translation layer/router that converts Claude Code’s Anthropic requests to the provider’s API.
Do not assume every Kimi endpoint is automatically Claude Code compatible.
Can Claude Code use GLM?
The same rule applies: verify Anthropic Messages API and tool-use compatibility for the exact provider, or use a compatible gateway.
Can Claude Code use Qwen?
Yes through an appropriate provider or compatibility layer, but the setup depends on where you access Qwen. Check tool calling, streaming and Anthropic API translation rather than looking only at the model name.
Is DeepSeek cheaper than Claude?
At current official API prices, DeepSeek V4 Flash and V4 Pro have substantially lower raw input/output token prices than Claude Sonnet 5 or Opus 5.
However, measure cost per successful task, not only price per million tokens.
Is DeepSeek as good as Claude Code?
That is the wrong comparison.
Claude Code is the coding-agent harness. DeepSeek is a model.
Compare:
Claude Code + DeepSeekvs.Claude Code + ClaudeWhat is the best cheap model for Claude Code?
DeepSeek is currently the easiest starting recommendation because it has an official Claude Code integration and explicit V4 Pro/Flash routing.
Kimi, GLM and Qwen are also worth testing when your chosen provider has reliable Anthropic/tool-call compatibility.
Should I replace Claude completely?
Usually not on day one.
Start with a hybrid workflow. Put routine, high-volume coding on the cheaper model and keep Claude available for planning, hard debugging, architecture and final review.
Summary
Claude Code and the Claude model are separate layers.
If the Claude Code workflow is what you like and the model cost is what you dislike, replace the model first.
DeepSeek is currently the strongest place to start because it officially documents Claude Code integration, Anthropic API compatibility, V4 Pro/Flash model routing and subagent configuration.
Use lower-cost models for routine implementation and high-volume agent work. Keep Claude as the escalation path when the task becomes difficult enough that reliability matters more than token price.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
- 👨💻 Claude Code documentation
- 👨💻 Claude Code settings
- 👨💻 Anthropic Messages API
- 👨💻 DeepSeek: Integrate with Claude Code
- 👨💻 DeepSeek Anthropic API compatibility
- 👨💻 DeepSeek models and pricing
- 👨💻 Claude API pricing
- 👨💻 OpenRouter
- 👨💻 LiteLLM
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments