POST
/v1/chat/completions原生 OpenAI 聊天格式
使用原生 OpenAI 格式进行对话补全,支持流式输出和多种模型。
请求地址
POST https://token.wlj.weifaner.net:8001/v1/chat/completions请求头
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
Authorization | string | 是 | Bearer Token 认证 |
Content-Type | string | 是 | application/json |
请求体
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 ID,如 gpt-4, gpt-3.5-turbo |
messages | array | 是 | 对话消息列表 |
stream | boolean | 否 | 是否使用流式输出(默认 false) |
temperature | number | 否 | 采样温度,范围 0-2(默认 1) |
max_tokens | integer | 否 | 最大生成 token 数 |
请求示例
curl -X POST https://token.wlj.weifaner.net:8001/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{"role": "system", "content": "你是一个有用的助手。"},
{"role": "user", "content": "你好!"}
],
"temperature": 0.7
}'响应示例
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1699000000,
"model": "gpt-3.5-turbo",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好!很高兴为你服务。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 10,
"total_tokens": 30
}
}最后更新于 2026/5/25