Skip to content
Aventail™ investigation into UK government AI dependence featured in Computer Weekly.Read the story
Aventail™
All guides

Claude Code + DeepSeek: setup, limits and where your code goes

13 min read

Run Claude Code on DeepSeek: the base URL, variables and model names from DeepSeek's docs, what breaks, where prompts are stored and the open-weight path.

Claude Code runs on DeepSeek's models through DeepSeek's Anthropic-compatible endpoint at https://api.deepseek.com/anthropic. Set that base URL, a DeepSeek API key and DeepSeek's model names in environment variables, and Claude Code sends every model request to DeepSeek and bills your DeepSeek balance.

As of 15 November 2026 the endpoint serves two models: deepseek-flash (DeepSeek-V4.1-Flash-1017) and deepseek-v4-pro. The API is run by Hangzhou DeepSeek Artificial Intelligence Co., Ltd., and its privacy policy says data is stored in the People's Republic of China. This guide gives the setup from DeepSeek's own docs, how to check which model answered, what does not work, what DeepSeek's terms say about your prompts, the open-weight path on your own hardware, and the same setup for a team.

What you need

Value on 15 November 2026

Claude Code

Any current version. Anthropic's native installer, or npm with Node.js 22 or later

DeepSeek account

An API key from platform.deepseek.com and a prepaid balance

Base URL

https://api.deepseek.com/anthropic

Models

deepseek-flash (DeepSeek-V4.1-Flash-1017) and deepseek-v4-pro (DeepSeek-V4-Pro-0813)

Context and output

1M tokens of context, up to 384K tokens of output, both models

deepseek-flash price per 1M tokens

Input $0.30, cached input $0.006, output $1.20 at peak. Half that off-peak

deepseek-v4-pro price per 1M tokens

Input $1.32, cached input $0.044, output $3.96 at peak. Half that off-peak

Concurrency per account

2,500 requests for deepseek-flash, 500 for deepseek-v4-pro

Anthropic account

Not needed for model requests

Peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC, Monday to Friday, excluding Chinese public holidays.

The legacy names deepseek-chat and deepseek-reasoner were due to be discontinued on 24 July 2026. deepseek-v4-flash is still accepted and is served by the V4.1 Flash model. If a guide uses any of those names, use deepseek-flash.

Step 1: install Claude Code

macOS, Linux and WSL:

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell:

irm https://claude.ai/install.ps1 | iex

DeepSeek's guide uses npm instead:

npm install -g @anthropic-ai/claude-code
claude --version

DeepSeek's page asks for Node.js 18 or later. Anthropic's setup page says the npm package needs Node.js 22 or later, so use 22.

Step 2: create a DeepSeek API key

Sign in to the DeepSeek Platform, create an API key and add balance. The service is prepaid: usage is deducted from the balance, and DeepSeek can suspend service when it runs out. Keep the key out of the repository.

Step 3: point Claude Code at DeepSeek

These are the lines DeepSeek publishes for macOS and Linux:

export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<your DeepSeek API Key>
export ANTHROPIC_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-flash[1m]
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-flash
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-flash
export CLAUDE_CODE_EFFORT_LEVEL=max
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432

Windows PowerShell:

$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="<your DeepSeek API Key>"
$env:ANTHROPIC_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-flash"
$env:CLAUDE_CODE_EFFORT_LEVEL="max"
$env:CLAUDE_CODE_AUTO_COMPACT_WINDOW="786432"

Then start Claude Code in the project:

cd /path/to/my-project
claude

What each line does:

  • ANTHROPIC_BASE_URL ends at /anthropic. Claude Code adds /v1/messages itself. A base URL that ends in /v1 asks for a path that does not exist.

  • ANTHROPIC_AUTH_TOKEN is sent as a bearer token. DeepSeek accepts either x-api-key or Authorization: Bearer.

  • ANTHROPIC_MODEL is the main model. The [1m] suffix tells Claude Code the model has a 1M-token window.

  • ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_HAIKU_MODEL set what the opus, sonnet and haiku aliases resolve to. The Haiku alias also runs Claude Code's background tasks.

  • CLAUDE_CODE_SUBAGENT_MODEL sets the model for subagents.

  • CLAUDE_CODE_EFFORT_LEVEL=max sets the thinking effort. While it is set, /effort in a session has no effect.

  • CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432 makes Claude Code compact the conversation at about 786K tokens.

Step 4: make it permanent

Shell exports last for one terminal. To keep the configuration, put the same variables in the env block of ~/.claude/settings.json:

{
"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"
}
}

This file holds the key in plain text. Do not commit it.

Step 5: choose between Flash and Pro

DeepSeek's own example keeps every alias on deepseek-flash. To send the opus alias to the larger model, set ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro.

DeepSeek also maps Claude model names on its side. Any name that starts with claude-opus is served by deepseek-v4-pro and billed at the Pro price. Names that start with claude-sonnet or claude-haiku are served by deepseek-flash. If you leave an alias variable unset, Claude Code sends a Claude name and DeepSeek picks the model for you. Set every alias so the bill matches what you chose.

Step 6: check which model answered

Call the endpoint directly. This request is built from DeepSeek's Messages API reference:

curl -sS https://api.deepseek.com/anthropic/v1/messages \
-H "x-api-key: $DEEPSEEK_API_KEY" \
-H "content-type: application/json" \
-d '{"model": "deepseek-flash", "max_tokens": 16, "messages": [{"role": "user", "content": "Hello"}]}'

The response carries a model field. "model": "deepseek-flash" means the key and the endpoint work. Then run /status inside Claude Code and check that the base URL line shows https://api.deepseek.com/anthropic and the model line shows the DeepSeek name you set.

To go back to Anthropic, remove the variables from the shell and from settings.json, open a new terminal and sign in again.

What works and what does not on DeepSeek

Works: chat, reading and editing files, running commands, the agent loop, streaming, thinking, CLAUDE.md, and web search. DeepSeek says its API supports Claude Code's Web Search tool natively. Searches are billed at $0.75 per 1,000, plus the tokens used to summarise the results.

Does not work, or works differently:

  • Anthropic does not support it. Anthropic's documentation says it "doesn't support routing Claude Code to non-Claude models through any gateway". It runs, and a Claude Code update can change that.

  • cache_control is ignored. DeepSeek caches request prefixes automatically on its side, so cache hits are billed at the lower price, but Claude Code's own cache markers have no effect.

  • Images depend on the model. deepseek-flash accepts images in user messages. deepseek-v4-pro does not process images and replaces them with the text [Unsupported Image].

  • Thinking controls are coarse. thinking accepts enabled or disabled; adaptive is treated as enabled and budget_tokens is ignored. Only effort is read from output_config.

  • max_tokens is not a hard cap. For some main-agent requests from Claude Code in thinking mode, DeepSeek raises the effective limit above the requested value.

  • Forced tool choice fails in thinking mode. tool_choice of any or a named tool returns a 400 error in thinking mode when only client tools are declared.

  • Some block types are not supported: redacted_thinking, search_result, code execution results and API-side MCP blocks. The mcp_servers request field is ignored.

  • Claude.ai features are off. Connectors from claude.ai load only when a claude.ai subscription is the active login, and Remote Control is disabled whenever ANTHROPIC_BASE_URL points at a host other than api.anthropic.com.

  • Rate limits are per account. Above the concurrency limit DeepSeek returns HTTP 429.

Where DeepSeek hosts the API and what it does with prompts

These are the statements in DeepSeek's own documents, read on 15 November 2026.

Question

What DeepSeek's documents say

Who operates the API

Hangzhou DeepSeek Artificial Intelligence Co., Ltd., "with its registered address in China"

Where data is stored

"We directly collect, process and store your Personal Data in People's Republic of China"

What is collected

Prompts, uploaded files and chat history ("Inputs"), account data, device and network data, logs

Use for training

The privacy policy lists "to train and improve our technology, such as our machine learning models and algorithms" as a purpose, and lists a right to opt out of that use

How long it is kept

"For as long as necessary to provide our Services". Account, input and payment data are kept "for as long as you have an account"

Disclosure to authorities

DeepSeek may share data to "comply with applicable law, legal process or government requests"

Governing law for the API

"The laws of the People's Republic of China in the mainland", with disputes heard where Hangzhou DeepSeek is registered

UK and EU representative

Prighter Group

Three points are not stated in the pages we read. The Open Platform Terms of Service (effective 29 April 2026) do not give a retention period for API inputs, do not say whether API inputs are excluded from training, and do not offer a zero-retention option. The privacy policy (last updated 10 February 2026) says it does not cover the end users of applications built on the open platform; the developer is the controller for those. If your organisation needs these points in writing, ask DeepSeek before you send source code.

Our guide to whether DeepSeek is safe for work covers the app and the wider policy question.

The alternative: DeepSeek's open weights on your own hardware

DeepSeek publishes its model weights on Hugging Face under the MIT licence. Running them yourself means the DeepSeek API is not involved and DeepSeek's terms above do not apply to your prompts. The sizes below were read on 15 November 2026.

Model

Where

Size on disk

Notes

DeepSeek-V4.1-Flash-1017

Hugging Face, deepseek-ai

510 GB of weights

The model behind deepseek-flash. 1M context. MIT

DeepSeek-V4-Flash-0731

Hugging Face, deepseek-ai

167 GB of weights

Previous Flash generation. MIT

DeepSeek-V4-Pro-0813

Hugging Face, deepseek-ai

893 GB of weights

The model card's example serves it with vLLM on one node with four NVIDIA GB300 GPUs. MIT

DeepSeek-V4.1-Flash-1017 GGUF

Hugging Face, unsloth (community build)

250 GB to 501 GB by quantisation

Not a DeepSeek release

deepseek-r1:14b

Ollama library

9.0 GB, 128K context

Tagged tools and thinking

deepseek-r1:32b

Ollama library

20 GB, 128K context

Tagged tools and thinking

deepseek-r1:70b

Ollama library

43 GB, 128K context

Tagged tools and thinking

deepseek-v3.1

Ollama library

404 GB, 160K context

Tagged tools and thinking

The whole set of weights has to be loaded, so plan for memory above the size on disk. The current Flash and Pro models are server-class: hundreds of gigabytes across several data-centre GPUs. The DeepSeek-R1 distills fit a workstation, but they are 2025 reasoning models and are not the model the API serves today. Test tool calls on a real edit before you rely on one.

Two entries in the Ollama library look local and are hosted: deepseek-v4.1-flash:cloud and deepseek-v4-pro:cloud run on Ollama's servers. They have no downloadable tag.

Once a model is served on your network through an Anthropic-compatible API, the Claude Code side is the same as in our guide to Claude Code with Ollama: change the base URL to your server and use the model name it serves.

The same models for a team with Aventail™ Connect

The steps above suit one developer. They leave an API key in each shell profile, and they give a security lead no record of which machine sent which request where.

Aventail™ Connect configures Claude Code to send its model requests through Aventail™ Link, the inference engine and gateway that runs on each machine. Routing rules are set in Aventail™ Control and evaluated on the device. Claude Code, Claude Desktop, OpenCode and Codex are supported.

For the open-weight path, the docs support this much:

  1. Serve the model in Link. Link runs GGUF language models. Choose one from the Aventail™ Library, or upload a custom GGUF in Control and test it on one device. An accepted upload does not prove the model will run.

  2. Use a server for large models. A model too big for laptops can sit on one internal machine running Link. A rule can name that machine as a network peer, provided it offers the exact model and has Serve other devices enabled. Peer routing is in beta.

  3. Connect Claude Code. In Link, open Connected apps and choose Connect next to Claude. There is no endpoint or key to enter. Claude Code needs at least 64K context.

  4. Write the rule. Permit only On device, or only the peer. If that destination is unavailable, the request fails with an error and is not sent elsewhere.

  5. Check the record. Send a harmless prompt and confirm the destination in Requests in Control.

Tool calling varies between builds of the same model, so test tool use with harmless code first. Free covers three connected devices. Starter is £50 a month excluding VAT with ten devices included. Routing policies need Control for Enterprise.

Which path to take

DeepSeek API by hand

DeepSeek weights on your own server

Open weights with Aventail™ Connect

Who it suits

One developer, non-sensitive code

A team with GPU capacity and someone to run it

A team whose code must stay on approved machines

Setup

Nine environment variables

vLLM or SGLang, then a base URL per developer

Connect button in Link, rules in Control

Where prompts are processed

DeepSeek's servers in China

Your hardware

Where the routing rule says, evaluated on the device

Terms that cover your prompts

DeepSeek's, under PRC law

Your own

Your own

Record of requests

None on your side

Whatever your server logs

Requests view in Control

If the endpoint is down

Requests fail

Requests fail

Fails closed, or falls back to an approved destination

Cost

From $0.15 per 1M input tokens off-peak

Hardware and power

Free for three devices; £50 a month for ten

Frequently asked questions

Can I use Claude Code with only a DeepSeek API key?
Yes. With ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN set, Claude Code sends model requests to DeepSeek and the usage is billed to your DeepSeek balance. A Claude subscription is not used for those requests.

Which DeepSeek model should I use in Claude Code?
DeepSeek's guide sets every alias to deepseek-flash, which is DeepSeek-V4.1-Flash-1017 with a 1M context window. deepseek-v4-pro costs about four times as much for input and does not accept images.

How much does DeepSeek cost in Claude Code?
deepseek-flash is $0.30 per 1M input tokens and $1.20 per 1M output tokens at peak, half that off-peak, and $0.006 per 1M for cached input. Web searches are $0.75 per 1,000. Long sessions at maximum effort use more output tokens.

Is my code sent to China when I use DeepSeek in Claude Code?
Model requests go to api.deepseek.com. DeepSeek's privacy policy says it collects, processes and stores data in the People's Republic of China.

Does DeepSeek train on API prompts?
DeepSeek's privacy policy lists model training as a purpose for the data it collects and gives a right to opt out. The Open Platform terms we read do not state whether API inputs are excluded. Ask DeepSeek in writing if this matters.

Can I run DeepSeek locally with Claude Code?
Yes, with the open weights. The current Flash model is 510 GB and needs server GPUs. The DeepSeek-R1 distills in the Ollama library run on a workstation from 9 GB.

How do I switch Claude Code back to Claude?
Remove the ANTHROPIC_* variables from your shell and from ~/.claude/settings.json, open a new terminal, and log in again.

Sources

  1. DeepSeek, Integrate with Claude Code: https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code

  2. DeepSeek, Using the Anthropic API: https://api-docs.deepseek.com/guides/anthropic_api

  3. DeepSeek, Create Message (Messages API reference): https://api-docs.deepseek.com/api/create-message

  4. DeepSeek, Models and Pricing: https://api-docs.deepseek.com/quick_start/pricing

  5. DeepSeek, Rate Limit and Isolation: https://api-docs.deepseek.com/quick_start/rate_limit

  6. DeepSeek, Context Caching: https://api-docs.deepseek.com/guides/kv_cache

  7. DeepSeek, Change Log: https://api-docs.deepseek.com/updates

  8. DeepSeek Privacy Policy (last updated 10 February 2026): https://cdn.deepseek.com/policies/en-US/deepseek-privacy-policy.html

  9. DeepSeek Open Platform Terms of Service (effective 29 April 2026): https://cdn.deepseek.com/policies/en-US/deepseek-open-platform-terms-of-service.html

  10. Hugging Face, deepseek-ai: DeepSeek-V4.1-Flash-1017, DeepSeek-V4-Flash-0731, DeepSeek-V4-Pro-0813: https://huggingface.co/deepseek-ai

  11. Hugging Face, unsloth/DeepSeek-V4.1-Flash-1017-GGUF: https://huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF

  12. Ollama library: deepseek-r1, deepseek-v3.1, deepseek-v4.1-flash, deepseek-v4-pro: https://ollama.com/search?q=deepseek

  13. Anthropic, Claude Code setup: https://code.claude.com/docs/en/setup

  14. Anthropic, Claude Code environment variables: https://code.claude.com/docs/en/env-vars

  15. Anthropic, Model configuration: https://code.claude.com/docs/en/model-config

  16. Anthropic, Other LLM gateways: https://code.claude.com/docs/en/llm-gateway

  17. Anthropic, Feature availability: https://code.claude.com/docs/en/feature-availability

  18. Aventail™, Connect overview: https://docs.aventail.co.uk/docs/connect/overview

  19. Aventail™, Routing: https://docs.aventail.co.uk/docs/fleet/routing

  20. Aventail™, Compatibility and versions: https://docs.aventail.co.uk/docs/introduction/versions-and-supported-models

  21. Aventail™, Manage models: https://docs.aventail.co.uk/docs/guides/models

  22. Aventail™, Pricing: https://aventail.co.uk/#pricing

All sources were read on 15 November 2026. DeepSeek serves its privacy policy by region, and our connection was redirected to the Korean edition (updated 6 May 2026). The global English edition quoted here was read through a web reader from the same URL.

We use optional cookies and tracking to identify visiting companies, load our contact form, measure Google Ads download clicks and understand page use with PostHog on our homepage, Connect and How it works pages, Ollama and LM Studio comparison guides and campaign pages. Cookie policy