Skip to content
NEW GPT-5.5 / Claude 4.6 已上线,立即体验 →
zh-api-reference API 参考 5 min read

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 }
}