Claude Code Is Expensive? Try Connecting to DeepSeek

Aug 22, 2025 · 3 min read · 440 Words · -Views -Comments

I subscribe to Claude Pro, but the quota is limited and often runs out. Yesterday DeepSeek released v3.1 and also provided a ClaudeCode-compatible API. Today I tried connecting Claude Code to DeepSeek. If you have network issues or insufficient quota for ClaudeCode, you can try DS. I think it is pretty good, so I am noting the steps here.

Shell configuration

Open ~/.zshrc or ~/.bashrc and add the following:

export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=sk-
export ANTHROPIC_MODEL=deepseek-chat
export ANTHROPIC_SMALL_FAST_MODEL=deepseek-chat

For ANTHROPIC_AUTH_TOKEN, get it at https://platform.deepseek.com/api_keys.

api key

After configuring, restart your terminal session or run source ~/.zshrc or source ~/.bashrc to apply the changes.

Launch Claude Code

Type claude in the terminal. If the proxy is configured correctly, you will see the proxied service URL in the output.

│   • API Base URL:                                 │
│   https://api.deepseek.com/anthropic

api key

Now you can use the DeepSeek version of ClaudeCode. The experience is basically the same as Claude, since only the model is changed.

Flexible switching between DeepSeek and Claude

With the method above, you can only use DeepSeek models. If you want to switch back to Claude, you would have to comment out the environment variables and restart the terminal. That is too annoying, so here is a more flexible approach.

alias claudeds="claude --settings '{\"env\":{\"ANTHROPIC_BASE_URL\":\"https://api.deepseek.com/anthropic\",\"ANTHROPIC_AUTH_TOKEN\":\"sk-\",\"ANTHROPIC_MODEL\":\"deepseek-chat\",\"ANTHROPIC_SMALL_FAST_MODEL\":\"deepseek-chat\"}}'"

After setting this alias, in any terminal session, use claudeds for DeepSeek and claude for Claude. No need to toggle environment variables.

Note: settings passed via command line have the highest priority, but they still merge with config files in the current directory and in the user home directory.

Current DS issues

After using it, I think DS is still a bit behind.

  1. Request speed is slower than Claude, but acceptable.
  2. AI understanding is weaker. For example, if you ask it to translate a Markdown article without modifying certain meta fields, it still changes them. Code generation is also not as good as Claude. But it is cheaper, so for general scenarios it is fine.

Pricing note

DeepSeek API gives some free credit at registration. If it runs out, you need to top up. DS is cheaper than Claude, so costs are lower. Still, keep an eye on it because Claude Code consumes tokens.

I used DS for one hour to translate an article and spent a bit over 3 RMB. Not bad.

Final Thoughts

I think it is great that DS provides a compatible API. It saves the effort of building a separate CLI and gives users a cheaper way to use ClaudeCode. Although DS is still slower and weaker in code quality than Claude, it is good enough for general usage. If you have not tried it, give it a shot.

✈️推荐

SS

支持Visa/支付宝支付,该方案适合不想自建节点的朋友,稳定性高,不用折腾。

Surge ClashX 订阅 QuantumultX
了解一下
Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover