Configure DeepSeek API for Claude Code and Cline
Connect DeepSeek-V3 and DeepSeek-R1 to Claude Code and VS Code Cline to run AI code generation and agent workflows with your own API key.
On this page
Generate an API key from the DeepSeek Platform (starting with sk-) and confirm your account balance before connecting.
Claude Code (terminal CLI) configuration
Configure Claude Code to route requests through DeepSeek via environment variables.
Add these lines to your shell profile (~/.zshrc or ~/.bashrc):
# macOS / Linux
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
export ANTHROPIC_API_KEY="sk-your_deepseek_api_key"
# Optional: explicit model designation
export ANTHROPIC_MODEL="deepseek-chat"For Windows PowerShell sessions:
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_API_KEY="sk-your_deepseek_api_key"
$env:ANTHROPIC_MODEL="deepseek-chat"ANTHROPIC_API_KEY unset and use export ANTHROPIC_AUTH_TOKEN="sk-your_key". Run claude and use /status to inspect the endpoint.VS Code extension setup (Cline / Roo Code)
- Install Cline or Roo Code from the VS Code Marketplace.
- Open the extension panel and click Settings ⚙️.
- Set API Provider to DeepSeek (or OpenAI Compatible).
- Paste your key into DeepSeek API Key.
- Choose deepseek-chat for daily coding or deepseek-reasoner for architecture planning.
- Base URL:
https://api.deepseek.comorhttps://api.deepseek.com/v1 - Model ID:
deepseek-chatordeepseek-reasoner
Claude Desktop proxy setup
Claude Desktop enforces official Anthropic signatures. Use a local gateway (like LiteLLM or deepseek-claude-proxy) to bridge the protocols:
# Example: run a local LiteLLM bridge
pip install litellm
litellm --model deepseek/deepseek-chat --api_base https://api.deepseek.com --port 8000Send a test prompt
Send a safe read-only message in your client:
Reply only with "DeepSeek connected successfully." Do not modify files.Common errors and solutions
401 Unauthorized / Authentication Error
Ensure the key begins with sk- with no surrounding whitespace. Do not use your web password.
402 Insufficient Balance
API usage is billed separately from web subscriptions. Top up your balance in the DeepSeek Platform.
Tool calling failures with Reasoning models
deepseek-reasoner focuses on pure reasoning. Use deepseek-chat when the agent invokes tools and executes commands.