GPT-5.4 对话

GPT-5 第四代,更强的通用推理与多模态能力

POST/v1/chat/completions
  • 兼容 OpenAI Chat Completions API 格式
  • 通过 model 参数指定 gpt-5.4 模型
  • 支持流式输出(SSE)
  • 支持多轮对话、系统提示词、视觉输入

Authorizations

Authorizationstring必填

所有接口均需要使用 Bearer Token 进行认证

获取 API Key:访问 API Key 管理页面 获取您的 API Key

使用时在请求头中添加:

Authorization: Bearer YOUR_API_KEY

Body

modelstring必填默认 gpt-5.4

模型名称

示例:"gpt-5.4"

messagesobject[]必填

对话消息列表,按时间顺序排列

显示隐藏 messages[n]
rolestring必填

消息角色,可选值 system、user、assistant

contentstring必填

消息内容,字符串或内容块数组(支持图片)

streamboolean默认 false

是否启用流式输出(Server-Sent Events)

  • true:逐 token 流式返回
  • false:等待完整响应后一次性返回
max_tokensinteger

生成内容的最大 token 数量

不设置时使用模型默认上限

temperaturenumber默认 1

采样温度,控制输出随机性

  • 范围:0 ~ 2
  • 值越低输出越稳定,值越高输出越随机
top_pnumber默认 1

核采样概率阈值

范围:0 ~ 1,建议不要同时修改 temperature 和 top_p

stopstring | string[]

停止序列,遇到指定字符串时停止生成

最多 4 个停止序列

Response

idstring

本次请求的唯一标识符

objectstring

对象类型,固定为 chat.completion

createdinteger

请求创建时间(Unix 时间戳)

modelstring

实际使用的模型名称

choicesobject[]

生成结果列表

  • choices[].message.role:消息角色,固定为 assistant
  • choices[].message.content:生成的文本内容
  • choices[].finish_reason:结束原因,stop / length / content_filter
  • choices[].index:结果索引
usageobject

本次请求的 token 消耗统计

  • usage.prompt_tokens:输入 token 数
  • usage.completion_tokens:输出 token 数
  • usage.total_tokens:总 token 数