Route DeepSeek R1, DeepSeek V3, and Qwen3 models through SiliconFlow via TheRouter — no code changes required, automatic failover from Bedrock.
This guide shows how to use DeepSeek R1, DeepSeek V3.2, and Qwen3 models through SiliconFlow via TheRouter. SiliconFlow is a China-region AI inference provider on Aliyun. TheRouter routes to SiliconFlow automatically when Bedrock is unavailable, or when China-optimized routing is enabled. The API is OpenAI-compatible — just change the base URL and API key. DeepSeek R1 returns reasoning_content in the response which TheRouter preserves end-to-end.
TheRouter is OpenAI-compatible. Set the base URL to https://api.therouter.ai/v1 and use your TheRouter API key. SiliconFlow routing happens automatically.
from openai import OpenAI
client = OpenAI(
api_key="YOUR_THEROUTER_API_KEY",
base_url="https://api.therouter.ai/v1",
)
response = client.chat.completions.create(
model="deepseek/deepseek-v3.2",
messages=[
{"role": "user", "content": "Explain the difference between TCP and UDP."}
],
)
print(response.choices[0].message.content)curl https://api.therouter.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $THE_ROUTER_API_KEY" \
-d '{
"model": "deepseek/deepseek-v3.2",
"messages": [
{"role": "user", "content": "Explain the difference between TCP and UDP."}
]
}'import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.THE_ROUTER_API_KEY,
baseURL: "https://api.therouter.ai/v1",
});
const response = await client.chat.completions.create({
model: "deepseek/deepseek-v3.2",
messages: [
{ role: "user", content: "Explain the difference between TCP and UDP." },
],
});
console.log(response.choices[0].message.content);Streaming works the same as any OpenAI-compatible provider:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_THEROUTER_API_KEY",
base_url="https://api.therouter.ai/v1",
)
stream = client.chat.completions.create(
model="deepseek/deepseek-r1",
messages=[{"role": "user", "content": "Write a haiku about distributed systems."}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
print()DeepSeek R1 returns a reasoning_content field alongside the main response. TheRouter preserves this field end-to-end when routing through SiliconFlow.
The reasoning_content contains the model's internal chain-of-thought and is available in both streaming and non-streaming responses:
import json
import httpx
response = httpx.post(
"https://api.therouter.ai/v1/chat/completions",
headers={
"Authorization": "Bearer YOUR_THEROUTER_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "deepseek/deepseek-r1",
"messages": [
{"role": "user", "content": "What is 17 * 23? Show your reasoning."}
],
},
)
data = response.json()
choice = data["choices"][0]
# The main answer
print("Answer:", choice["message"]["content"])
# DeepSeek R1 chain-of-thought (preserved by TheRouter)
reasoning = choice["message"].get("reasoning_content")
if reasoning:
print("Reasoning:", reasoning[:200], "...")DeepSeek V3 and Qwen3 models support function calling. Use the standard OpenAI tools format:
from openai import OpenAI
client = OpenAI(
api_key="YOUR_THEROUTER_API_KEY",
base_url="https://api.therouter.ai/v1",
)
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["city"],
},
},
}
]
response = client.chat.completions.create(
model="deepseek/deepseek-v3.2",
messages=[{"role": "user", "content": "What's the weather in Beijing?"}],
tools=tools,
tool_choice="auto",
)
print(response.choices[0].message.tool_calls)The following models are routed through SiliconFlow when available. All use standard model IDs — never SiliconFlow-specific names:
| Model ID | Description | Input / Output ($/MTok) |
|---|---|---|
deepseek/deepseek-r1 | Reasoning model with chain-of-thought | $0.55 / $2.19 |
deepseek/deepseek-v3.2 | Fast, cost-efficient text model | $0.14 / $0.28 |
deepseek/deepseek-v3.1 | Earlier generation V3 | $0.14 / $0.28 |
qwen/qwen3-235b | Alibaba flagship MoE model | $0.14 / $0.55 |
qwen/qwen3-32b | Dense model with tools + reasoning | $0.03 / $0.07 |
qwen/qwen3-coder-480b | Specialized code model | $0.35 / $1.40 |
qwen/qwen3-coder-30b | Lightweight code model | $0.03 / $0.07 |
qwen/qwen3-next-80b | Preview via Qwen3-30B-A3B | $0.03 / $0.07 |
TheRouter uses a two-tier routing strategy for SiliconFlow models:
You can also set a provider preference per API key from the dashboard to always prefer SiliconFlow for cost optimization.