Skip to content

对话补全

接口

POST /v1/chat/completions

请求参数

参数类型必填说明
modelstring模型名称,如 gpt-5.3-codex-low
messagesarray对话消息列表
streamboolean是否流式输出,默认 false
max_tokensinteger最大输出 Token 数
temperaturenumber温度参数 0-2,默认 1
top_pnumber核采样参数
toolsarray工具定义(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
  }
}