DeepSeek uses the OpenAI chat-completions shape, so migrating to Anthropic is effectively OpenAI → Anthropic: switch SDKs, lift the system message to a top-level system, make max_tokens explicit, and read content[0].text.
API concept mapping
| Concept | DeepSeek | Anthropic |
|---|---|---|
| SDK | openai + base_url | anthropic |
| Auth | DEEPSEEK_API_KEY | x-api-key + anthropic-version |
| System prompt | messages[] role: system | top-level system param |
| Max output | max_tokens (optional) | max_tokens (required) |
| Assistant text | choices[0].message.content | content[0].text |
| Model | deepseek-chat / -reasoner | claude-sonnet-4-6 / haiku / opus |
| Tool result | role: tool message | tool_result content block |
Before / after
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."},
{"role": "user", "content": "Explain rate limits in one line."},
],
)
print(resp.choices[0].message.content) import anthropic
client = anthropic.Anthropic()
resp = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024, # now required
system="You are concise.", # lifted out of messages
messages=[{"role": "user", "content": "Explain rate limits in one line."}],
)
print(resp.content[0].text) Watch for these
- Switch SDKs (openai → anthropic) and drop the DeepSeek base URL/key.
- Lift the
systemmessage to the top-levelsystemparam; add a requiredmax_tokens. - Response path becomes
content[0].text. - Tools: OpenAI
tools/tool_calls→ Claudetoolswithinput_schema; returntool_resultblocks in a user message. - Handle
529 Overloadedalongside429on Anthropic. - Pricing rises — Claude is pricier than DeepSeek; re-budget.
What to do next
- Move the system message to top-level
system; set a requiredmax_tokens. - Switch to the Anthropic SDK; update parsing to
content[0].text. - Port tool schemas (
parameters→input_schema) and thetool_resultround-trip. - Re-price with the cost calculator; the mechanics match OpenAI → Anthropic, and the reverse is Anthropic → DeepSeek.
Frequently asked questions
Why does this look like OpenAI → Anthropic?
Because DeepSeek implements the OpenAI chat API, your DeepSeek code is already OpenAI-shaped. So the remap to Claude's Messages API is the same one you'd do from OpenAI: system prompt out, required max_tokens, new response path, different tool format.
What's required on Anthropic that wasn't on DeepSeek?
max_tokens is mandatory, the system prompt is a top-level field (not a message), and you should handle 529 Overloaded in addition to 429.Will my bill go up?
Likely — Claude models cost more than DeepSeek. Run the cost calculator on your real token counts before cutover so the increase is intentional.