DeepSeek
DeepSeek Chat Completions
通过 OpenAI 兼容端点调用 DeepSeek 模型,支持流式、工具调用、Thinking 与 JSON 模式。
POST
v1/chat/completionsAuthorizations
Authorizationstringheaderrequired
OpenAI 兼容通道:Bearer sk-pat-您的AccessToken
密钥的值使用 HAI Gateway 的个人访问令牌(以 sk-pat- 开头),无需在 DeepSeek 处单独申请 API Key。
Base URL
Body 参数
请求体格式与 OpenAI Chat Completions API 一致,详细参数说明请参考 DeepSeek 官方文档。
DeepSeek 注意事项
- 仅支持 Chat Completion 类通道:DeepSeek 不支持 OpenAI Responses (
/v1/responses) 端点,请使用/v1/chat/completions或 Anthropic/v1/messages。 - thinking 仅 pro 可用:
enable_thinking(OpenAI 通道)或thinking(Anthropic 通道)只在deepseek-v4-pro上生效;deepseek-v4-flash收到这两个参数会被忽略,不返回思考内容。 - 思考字段位置:思考链在 OpenAI 通道走
choices[].message.reasoning_content字段;在 Anthropic 通道走content数组里的thinking块。 - 多轮上下文不要回传 reasoning:拼接历史时只回传上一轮的
content(OpenAI)或text块(Anthropic),不要把reasoning_content/thinking块塞回messages,否则会报参数错误。 - 不支持 developer 角色:OpenAI 兼容入口只接受
system/user/assistant三种 role;Anthropic 通道遵循官方user/assistant对话结构,system 单独通过顶层system字段传入。
cURL
curl https://api.hai.network/compatible-preview/openai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-pat-您的Access Token" \
-d '{
"model": "deepseek-v4-flash",
"messages": [
{
"role": "user",
"content": "你好,请用一句话介绍自己"
}
]
}'200
{
"id": "chatcmpl-...",
"object": "chat.completion",
"model": "deepseek-v4-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "我是 DeepSeek,由深度求索研发的大语言模型。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 14,
"completion_tokens": 20,
"total_tokens": 34
}
}