DeepSeek via Anthropic SDK
Access DeepSeek models through the Anthropic SDK and Messages API
DeepSeek models are accessible through OpenModel's Messages protocol (/v1/messages), which means you use the Anthropic SDK to call them. The setup is identical to using Anthropic — just change the model name.
This guide also applies to the other Messages protocol providers: DashScope (Alibaba Cloud) and Xiaomi (MiMo). They all work through the same endpoint with the same SDK.
Available Models
| Provider | Example Models |
|---|---|
| DeepSeek | deepseek-v4-flash, deepseek-v4-pro |
| DashScope (Alibaba Cloud) | qwen3-max |
| Xiaomi (MiMo) | mimo-v2.5-pro, mimo-v2-flash |
See Available Models for the full list.
Installation
Install the Anthropic SDK — the same SDK used for Anthropic models:
pip install anthropicConfiguration
import anthropic
client = anthropic.Anthropic(
base_url="https://api.openmodel.ai",
api_key="om-your-api-key",
)The configuration is exactly the same as the Anthropic SDK page. Refer to that page for environment variable setup and additional configuration options.
Examples
Basic Message
import anthropic
client = anthropic.Anthropic(
base_url="https://api.openmodel.ai",
api_key="om-your-api-key",
)
message = client.messages.create(
model="deepseek-v4-flash",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain how a neural network learns."}
],
)
print(message.content[0].text)Streaming
import anthropic
client = anthropic.Anthropic(
base_url="https://api.openmodel.ai",
api_key="om-your-api-key",
)
with client.messages.stream(
model="deepseek-v4-flash",
max_tokens=1024,
messages=[
{"role": "user", "content": "Write a short story about a robot learning to paint."}
],
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
print()Using Other Providers
To switch between providers, just change the model parameter. The rest of the code stays the same:
# DashScope
message = client.messages.create(model="qwen3-max", max_tokens=1024, messages=[...])
# Xiaomi
message = client.messages.create(model="mimo-v2.5-pro", max_tokens=1024, messages=[...])Compatibility Notes
All Messages protocol providers support the core messaging features: text messages, multi-turn conversations, streaming, and system prompts. However, advanced features like tool use and vision may vary by provider. Check the API Reference for the full compatibility details.
Next Steps
- Anthropic SDK — Full SDK reference with advanced examples (tool use, async, etc.)
- Streaming — Real-time streaming responses
- Available Models — Browse all supported providers and models