DeepSeek speaks the OpenAI chat-completions API, so migrating from Anthropic is really “Anthropic → OpenAI shape, pointed at DeepSeek.” You remap Claude’s Messages format once, then use the OpenAI SDK with DeepSeek’s base URL.
API concept mapping
| Concept | Anthropic | DeepSeek |
|---|---|---|
| SDK | anthropic | openai + base_url |
| Base URL / auth | x-api-key | https://api.deepseek.com + DEEPSEEK_API_KEY |
| System prompt | top-level system param | messages[] with role: system |
| Max output | max_tokens (required) | max_tokens (optional) |
| Assistant text | content[0].text | choices[0].message.content |
| Model | claude-sonnet-4-6 | deepseek-chat / deepseek-reasoner |
| Tool result | tool_result content block | role: tool message |
Before / after
import anthropic
client = anthropic.Anthropic()
resp = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="You are concise.",
messages=[{"role": "user", "content": "Explain rate limits in one line."}],
)
print(resp.content[0].text) import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["DEEPSEEK_API_KEY"], base_url="https://api.deepseek.com")
resp = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "system", "content": "You are concise."}, # was top-level
{"role": "user", "content": "Explain rate limits in one line."},
],
)
print(resp.choices[0].message.content) Watch for these
- Switch SDKs (anthropic → openai) and set DeepSeek’s
base_url. - System prompt → a
systemmessage; response path →choices[0].message.content. - Tools: Claude
tool_use/tool_result→ OpenAItool_calls+role: toolresults;input_schema→parameters. deepseek-reasonerreturns reasoning content and longer outputs — handle and cost it separately.- Re-tune prompts and re-run evals; quality and formatting differ.
What to do next
- Remap Claude Messages → OpenAI-shape messages (system as a message, relax max_tokens).
- Use the OpenAI SDK with DeepSeek’s base URL and key; pick
deepseek-chator-reasoner. - Port tool schemas and result round-trips.
- DeepSeek is usually far cheaper — confirm with the cost calculator. The remap step mirrors Anthropic → OpenAI.
Frequently asked questions
Why is this the same as Anthropic → OpenAI?
Because DeepSeek implements the OpenAI chat-completions API. Once you've remapped Claude's Messages format to OpenAI's, you just point the OpenAI SDK at DeepSeek's base URL with a DeepSeek key.
Do I keep the Anthropic SDK?
No — swap to the
openai SDK and point its base URL at DeepSeek. The Anthropic SDK only speaks the Messages API.What about Claude's tool calling?
Convert
tool_use blocks to OpenAI tool_calls, return results as role: tool messages, and translate tool schemas from input_schema to parameters. Test the full round-trip.