Migrating from Anthropic to DeepSeek: A Practical Guide

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

Anthropic Messages → DeepSeek (OpenAI-compatible, as of June 2026).
ConceptAnthropicDeepSeek
SDK anthropicopenai + base_url
Base URL / auth x-api-keyhttps://api.deepseek.com + DEEPSEEK_API_KEY
System prompt top-level system parammessages[] with role: system
Max output max_tokens (required)max_tokens (optional)
Assistant text content[0].textchoices[0].message.content
Model claude-sonnet-4-6deepseek-chat / deepseek-reasoner
Tool result tool_result content blockrole: tool message

Before / after

Before — Anthropic
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)
After — DeepSeek (OpenAI SDK)
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 system message; response path → choices[0].message.content.
  • Tools: Claude tool_use/tool_result → OpenAI tool_calls + role: tool results; input_schemaparameters.
  • deepseek-reasoner returns 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

  1. Remap Claude Messages → OpenAI-shape messages (system as a message, relax max_tokens).
  2. Use the OpenAI SDK with DeepSeek’s base URL and key; pick deepseek-chat or -reasoner.
  3. Port tool schemas and result round-trips.
  4. 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.