外观
Chat Completions 请求
请求地址
text
POST https://api.cxbl.top/v1/chat/completions1
最小请求
http
POST /v1/chat/completions HTTP/1.1
Host: api.cxbl.top
Authorization: Bearer sk-你的令牌
Content-Type: application/json
{
"model": "你的模型名",
"messages": [
{"role": "user", "content": "用一句话介绍橙枢 AI"}
]
}1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
带 system prompt
json
{
"model": "你的模型名",
"messages": [
{"role": "system", "content": "你是一个简洁的中文助手。"},
{"role": "user", "content": "解释什么是 API 中转。"}
]
}1
2
3
4
5
6
7
2
3
4
5
6
7
多轮对话
多轮对话需要把必要历史继续放入 messages。模型不会自动记住客户端没有发送的内容。
json
{
"model": "你的模型名",
"messages": [
{"role": "user", "content": "记住数字 42"},
{"role": "assistant", "content": "好的。"},
{"role": "user", "content": "刚才的数字是什么?"}
]
}1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
使用建议
- 调试时先缩短上下文,确认基础链路正常。
- 不要把 API Key 放进前端代码或公开仓库。
- 生产环境记录请求 ID、模型名、耗时和错误摘要。
- 长上下文、复杂推理、图片和大量输出会增加耗时与消耗。