POST /v1/chat/completions
参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model |
string | 是 | 模型 ID(见模型目录) |
messages |
array | 是 | 对话消息列表,OpenAI 格式 |
max_tokens |
integer | 否 | 最大输出 tokens |
temperature |
number | 否 | 采样温度,0-2 |
stream |
boolean | 否 | 是否流式返回 |
请求示例
curl https://api.onefast.ai/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer sk-your-api-key"
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "你好"}],
"max_tokens": 100
}'
响应示例
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"model": "gpt-4o",
"choices": [{ "index": 0, "message": { "role": "assistant", "content": "你好!" } }],
"usage": { "prompt_tokens": 5, "completion_tokens": 20, "total_tokens": 25 }
}