Responses API

POST /v1/responses — OpenAI 新一代 Responses API,提供更灵活的对话控制和更结构化的响应格式。

概述

Responses API 是 OpenAI 推出的新一代对话接口,与 Chat Completions API 相比,它使用 input 替代 messages 数组,并提供了更丰富的输出格式控制。

特性Chat CompletionsResponses
输入格式messages 数组input 字段
输出格式choices 数组output 数组
状态管理支持异步任务状态
流式支持stream: truestream: true

请求示例

cURLBash
curl https://www.ulovegpt.com/v1/responses \
  -H "Authorization: Bearer <你的 API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.4-mini",
    "input": "解释一下量子计算的基本原理",
    "text": {
      "format": {"type": "text"}
    },
    "max_output_tokens": 1024
  }'

请求参数

参数类型必填说明
modelstring模型名称
inputstring/array输入内容,支持文本或消息对象
max_output_tokensinteger最大输出 token 数
text.formatobject输出格式控制(text / json_schema)
streamboolean是否启用流式输出
temperaturenumber采样温度

响应格式

响应示例Json
{
  "id": "resp_abc123",
  "object": "response",
  "created_at": 1704067200,
  "model": "openai/gpt-5.4-mini",
  "status": "completed",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "量子计算是一种利用量子力学原理进行信息处理的计算方式..."
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 20,
    "output_tokens": 128,
    "total_tokens": 148
  }
}