Migrating from DeepSeek to Anthropic: A Practical Guide

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

DeepSeek (OpenAI-compatible) → Anthropic Messages (as of June 2026).
ConceptDeepSeekAnthropic
SDK openai + base_urlanthropic
Auth DEEPSEEK_API_KEYx-api-key + anthropic-version
System prompt messages[] role: systemtop-level system param
Max output max_tokens (optional)max_tokens (required)
Assistant text choices[0].message.contentcontent[0].text
Model deepseek-chat / -reasonerclaude-sonnet-4-6 / haiku / opus
Tool result role: tool messagetool_result content block

Before / after

Before — DeepSeek
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)
After — Anthropic
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 system message to the top-level system param; add a required max_tokens.
  • Response path becomes content[0].text.
  • Tools: OpenAI tools/tool_calls → Claude tools with input_schema; return tool_result blocks in a user message.
  • Handle 529 Overloaded alongside 429 on Anthropic.
  • Pricing rises — Claude is pricier than DeepSeek; re-budget.

What to do next

  1. Move the system message to top-level system; set a required max_tokens.
  2. Switch to the Anthropic SDK; update parsing to content[0].text.
  3. Port tool schemas (parametersinput_schema) and the tool_result round-trip.
  4. 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.