主题
对话补全
接口
POST /v1/chat/completions请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | ✅ | 模型名称,如 gpt-5.3-codex-low |
messages | array | ✅ | 对话消息列表 |
stream | boolean | ❌ | 是否流式输出,默认 false |
max_tokens | integer | ❌ | 最大输出 Token 数 |
temperature | number | ❌ | 温度参数 0-2,默认 1 |
top_p | number | ❌ | 核采样参数 |
tools | array | ❌ | 工具定义(Function Calling) |
示例请求
json
{
"model": "gpt-5.3-codex-low",
"messages": [
{"role": "system", "content": "你是一个有帮助的助手。"},
{"role": "user", "content": "用 Python 写一个快速排序"}
],
"stream": false,
"max_tokens": 2048
}示例响应
json
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"model": "gpt-5.3-codex-low",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "```python\ndef quicksort(arr):\n ..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 30,
"completion_tokens": 150,
"total_tokens": 180
}
}