快速开始
接口地址
https://api.modelapihub.cn/v1/chat/completions
鉴权方式
Authorization: Bearer 用户Key
请求格式
OpenAI Chat Completions
推荐模型
deepseek-chat
模型
deepseek-chat:正式聊天模型。deepseek:deepseek-chat:带 provider 前缀的等价模型名。mock:test:内部测试模型,正式调用前请确认是否启用。
curl 示例
curl https://api.modelapihub.cn/v1/chat/completions \
-H "Authorization: Bearer 用户Key" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [
{"role": "user", "content": "你好,测试一下"}
]
}'
JavaScript 示例
const response = await fetch("https://api.modelapihub.cn/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer 用户Key",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "deepseek-chat",
messages: [
{ role: "user", content: "你好,测试一下" }
]
})
});
const data = await response.json();
console.log(data.choices[0].message.content);
Python 示例
import requests
response = requests.post(
"https://api.modelapihub.cn/v1/chat/completions",
headers={
"Authorization": "Bearer 用户Key",
"Content-Type": "application/json",
},
json={
"model": "deepseek-chat",
"messages": [
{"role": "user", "content": "你好,测试一下"}
],
},
timeout=60,
)
print(response.json()["choices"][0]["message"]["content"])
常见错误
Invalid API key:用户 Key 错误、被禁用,或没有带Bearer。Insufficient balance:余额不足,需要联系管理员充值。Model is disabled:模型已被管理员禁用。DEEPSEEK_API_KEY is not set:上游 Key 未配置。429 Too Many Requests:触发限流,稍后再试。