Skip to content

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

Claude Code using DeepSeek, Kimi, GLM and Qwen as cheaper AI model backends

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.

The important distinction
Claude Code = agent harness / CLI workflow
Claude 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:

A cost-conscious Claude Code workflow
routine coding / tests / repetitive work → lower-cost model
hard planning / architecture / final review → Claude

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

Claude Code architecture using DeepSeek V4 Pro and V4 Flash through the Anthropic-compatible API

DeepSeek exposes an Anthropic-compatible endpoint at:

https://api.deepseek.com/anthropic

That 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:

Claude Code + DeepSeek V4 on macOS/Linux
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:

Terminal window
cd /path/to/your/project
claude

That is a real, officially documented DeepSeek configuration rather than a generic proxy example.

Windows PowerShell setup

Claude Code + DeepSeek V4 on Windows
$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:

Terminal window
cd C:\path\to\your\project
claude

Model 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:

DeepSeek's Claude model mapping
claude-opus-* → deepseek-v4-pro
claude-sonnet-* / haiku-* → deepseek-v4-flash

The explicit environment-variable setup above can override that default behavior.

A practical configuration is:

A useful DeepSeek routing strategy
main model / hard work → DeepSeek V4 Pro
Opus role → DeepSeek V4 Pro
Sonnet role → DeepSeek V4 Pro
Haiku role → DeepSeek V4 Flash
subagents → DeepSeek V4 Flash

This 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:

~/.zshrc
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:

Terminal window
source ~/.zshrc

If 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:

Simple launcher idea
#!/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:

Normal Claude Code path
Claude Code
Anthropic Messages API
Claude

With a compatible provider:

Alternative-model path
Claude Code
Anthropic-compatible API
DeepSeek / another model

If a model provider does not expose the Anthropic Messages API directly, the path may instead look like:

Using a translation layer
Claude Code
LiteLLM / gateway / router
provider-native API
Kimi / GLM / Qwen / another model

The 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:

  1. Does it expose an Anthropic-compatible Messages API?
  2. Does it support tool calling correctly?
  3. Does it handle streaming and tool results in the way Claude Code expects?
  4. Can it map Claude model names?
  5. If not, does your gateway translate Anthropic requests reliably?

A practical way to think about the options is:

Model familyClaude Code pathWhy consider itWhat to verify
DeepSeekOfficial Anthropic-compatible integrationVery low cost, V4 Pro/Flash routing, official Claude Code docsCurrent model names and pricing
KimiProvider-dependent direct endpoint or gatewayLong-context ecosystem, competitive coding modelsAnthropic compatibility and tool calls
GLMProvider-dependent direct endpoint or gatewayLow-cost option, convenient for many China-based developersEndpoint behavior and model mapping
QwenProvider/gateway dependentStrong coding ecosystem and many deployment optionsClaude Code compatibility layer
ClaudeNativeHighest compatibility with Claude CodeHigher 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 familyMain reason to try itBest starting use
DeepSeekOfficial Claude Code integration plus aggressive API pricingRoutine coding, backend work, tests, debugging, subagents
KimiLong-context ecosystem and strong general/coding modelsLarge-context work, mixed coding/documentation
GLMAffordable general-purpose alternativeEveryday development and debugging
QwenBroad coding/open-model ecosystemCode generation, structured tasks, self-hosted/provider-specific setups
Claude Sonnet/OpusNative Claude Code behavior and stronger hard-task reliabilityComplex 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.

ModelInput cache missOutput
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:

ModelInputOutput
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:

Illustrative example only
Model A
$0.50 per attempt × 1 successful attempt = $0.50
Model B
$0.08 per attempt × 10 attempts/retries = $0.80

Model 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

Hybrid Claude Code workflow using DeepSeek for implementation and Claude for planning and review

The strongest cost-saving setup is often not:

Claude everywhere

and not:

cheap model everywhere

It is model escalation.

For example:

Hybrid workflow
Plan → Claude
Implement → DeepSeek V4 Pro
Subagents → DeepSeek V4 Flash
Tests → DeepSeek V4 Flash / Pro
Final review → Claude

Or a simpler workflow:

Routine task?
Try DeepSeek
Working well? ── Yes → keep going
↓ No
Escalate to Claude

An “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:

Cheap implementation, expensive judgment
lower-cost model → high-volume implementation
Claude → difficult reasoning and review

Where 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_result handling
  • 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:

Terminal window
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-flash

Provider 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:

  1. make the task smaller
  2. restart with a clean context
  3. reduce autonomy
  4. ask a stronger model to create the plan
  5. switch the implementation back to the cheap model
  6. 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 → Claude
personal side project → DeepSeek
large cheap subagents → DeepSeek Flash
high-risk review → Claude

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

QuestionPractical 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:

  1. the model provider’s official API
  2. a reputable gateway
  3. 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.

SetupKeep Claude Code?Main reason
Claude Code + ClaudeYesNative behavior and highest compatibility
Claude Code + DeepSeekYesOfficial low-cost alternative backend
Claude Code + KimiYesAlternative model if provider/gateway compatibility is good
Claude Code + GLMYesLow-cost alternative
Claude Code + QwenYesFlexible coding/model ecosystem
OpenCodeNoMore model/harness flexibility
CodexNoOpenAI-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 + DeepSeek
vs.
Claude Code + Claude Sonnet / Opus

For 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 / Pro

Use Flash aggressively for high-volume work and subagents.

Best balance

Plan / hard reasoning → Claude
Implementation → DeepSeek V4 Pro
Subagents / tests → DeepSeek V4 Flash
Review → Claude

Maximum reliability

Claude Code
+
Claude Sonnet / Opus

You pay more, but you remove most API compatibility uncertainty.


Decision tree

Which backend should I try?
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 first

FAQ

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/anthropic

Verify 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 + DeepSeek
vs.
Claude Code + Claude

What 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:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments