API 文档
OpenAI-compatible Chat Completions 接口。
接口地址
http://api.qianyi-ai.com.cn/v1/chat/completions
鉴权方式
Authorization: Bearer 用户API_KEY
API 状态
检查中...
curl 示例
curl -X POST http://api.qianyi-ai.com.cn/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"qwen3:14b","messages":[{"role":"user","content":"你好"}],"temperature":0.7}'JS 示例
const res = await fetch("http://api.qianyi-ai.com.cn/v1/chat/completions", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "qwen3:14b",
messages: [{ role: "user", content: "你好" }],
temperature: 0.7
})
});
const data = await res.json();Python 示例
import requests
res = requests.post(
"http://api.qianyi-ai.com.cn/v1/chat/completions",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
json={
"model": "qwen3:14b",
"messages": [{"role": "user", "content": "你好"}],
"temperature": 0.7,
},
)
print(res.json())返回格式示例
{
"id": "chatcmpl_xxxxx",
"object": "chat.completion",
"created": 1710000000,
"model": "qwen3:14b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "API模型调用成功"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 36,
"total_tokens": 48
}
}错误码说明
401
API Key 无效
402
余额不足
429
调用频率超限
500
模型网关错误