控制台 ↗
模型详情Responses

gpt-5.5

推理、工具、文件与视觉能力

能力概览

输入

文本图片文件

输出

文本

推荐接口

Responses API

图片理解

可结合文字提问,分析图片中的内容。

文件任务

适合围绕文件内容进行提取、归纳和推理。

工具调用

可由应用侧提供函数工具并处理调用结果。

结构化输出

可按业务定义的结构组织返回内容。

接口

POSThttps://www.yunqiai.chat/v1/responses

所有请求使用 HTTPS,并通过请求头携带访问密钥。

请求参数

参数类型说明
model必填string要调用的模型 ID
input必填string | array文本、消息或多模态输入项
max_output_tokensinteger取值从 16 起;最大输出量随模型变化
streamboolean是否以 SSE 流式返回,默认 false
temperaturenumber0–2;推理模型建议省略并使用模型默认值
top_pnumber0–1;与 temperature 通常只设置一个
toolsarray函数、Web 搜索、图像生成等工具定义
previous_response_idstring继续上一轮 Responses 会话
metadataobject可选业务元数据

请求示例

cURL
curl --request POST \
  --url https://www.yunqiai.chat/v1/responses \
  --header "Authorization: Bearer YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "gpt-5.5",
    "input": "用三句话解释量子计算",
    "max_output_tokens": 1024,
    "stream": false
  }'

Base64 图片输入

Responses 使用完整 Data URL;不要只传裸 Base64 字符串。

JSON · Base64
{
  "model": "gpt-5.5",
  "input": [
    {
      "role": "user",
      "content": [
        {
          "type": "input_text",
          "text": "描述这张图片"
        },
        {
          "type": "input_image",
          "image_url": "data:image/png;base64,BASE64_IMAGE_DATA",
          "detail": "low"
        }
      ]
    }
  ],
  "max_output_tokens": 256
}

文件输入

把文件作为 input_file 内容块传入,并在同一条消息中加入 input_text 说明任务。下面示例直接读取本地 PDF、编码为 Data URL,并遍历原始 output[] 打印结果。

Python · local PDF
import base64
import os
from pathlib import Path

import requests

file_path = Path("report.pdf")
file_data = base64.b64encode(file_path.read_bytes()).decode("ascii")
payload = {
    "model": "gpt-5.5",
    "input": [{
        "role": "user",
        "content": [
            {
                "type": "input_file",
                "filename": file_path.name,
                "file_data": f"data:application/pdf;base64,{file_data}",
            },
            {"type": "input_text", "text": "提取报告中的结论与关键数字"},
        ],
    }],
}

response = requests.post(
    "https://www.yunqiai.chat/v1/responses",
    headers={
        "Authorization": f"Bearer {os.environ['YUNQI_API_KEY']}",
        "Content-Type": "application/json",
    },
    json=payload,
    timeout=(10, 180),
)
response.raise_for_status()
result = response.json()

texts = [
    part["text"]
    for item in result.get("output", [])
    if item.get("type") == "message"
    for part in item.get("content", [])
    if part.get("type") == "output_text"
]
print("
".join(texts))
来源input_file 字段适用条件
内联 Data URLfile_data + filename本地文件可直接编码后发送
公开 URLfile_url文件地址可由服务端直接访问
已有文件 IDfile_id仅在业务侧已经取得有效 file_id 时使用
文件类型处理方式建议
PDF结合提取文本与页面图像理解内容扫描件、图表较多的文档优先使用 PDF
DOCX、PPTX、TXT 等提取可读取的文本内容需要保留图表或版式时先转换为 PDF
CSV、XLSX读取表格数据大型表格先筛选列与行,减少无关输入

流式输出

客户端以 SSE 逐行读取 data: 事件。不要按网络数据块直接解码 JSON;同一事件可能被拆成多个传输片段。

阶段事件读取内容
开始response.created响应 ID 与初始状态
文本增量response.output_text.deltadelta
工具调用response.output_item.added / response.function_call_arguments.delta保存 name 与 call_id,按 item_id 拼接参数;完成后再解析 JSON
完成response.completed最终响应与用量
失败或不完整response.failed / response.incomplete / error不要把已收到的增量标记为完整结果
Python · Responses SSE
import json
import os

import requests

payload = {
    "model": "gpt-5.5",
    "input": "用三句话解释量子计算",
    "stream": True,
}

with requests.post(
    "https://www.yunqiai.chat/v1/responses",
    headers={
        "Authorization": f"Bearer {os.environ['YUNQI_API_KEY']}",
        "Content-Type": "application/json",
    },
    json=payload,
    stream=True,
    timeout=(10, 180),
) as response:
    response.raise_for_status()
    completed = False
    tool_calls = {}

    for line in response.iter_lines(decode_unicode=True):
        if not line or not line.startswith("data: "):
            continue
        data = line[6:]
        if data == "[DONE]":
            break
        event = json.loads(data)
        event_type = event.get("type")
        if event_type == "response.output_text.delta":
            print(event.get("delta", ""), end="", flush=True)
        elif event_type == "response.output_item.added":
            item = event.get("item") or {}
            if item.get("type") == "function_call":
                item_id = item.get("id", str(event.get("output_index", 0)))
                tool_calls[item_id] = {
                    "call_id": item.get("call_id", ""),
                    "name": item.get("name", ""),
                    "arguments": item.get("arguments", ""),
                }
        elif event_type == "response.function_call_arguments.delta":
            item_id = event.get("item_id", str(event.get("output_index", 0)))
            current = tool_calls.setdefault(item_id, {"call_id": "", "name": "", "arguments": ""})
            current["arguments"] += event.get("delta", "")
        elif event_type == "response.function_call_arguments.done":
            item_id = event.get("item_id", str(event.get("output_index", 0)))
            current = tool_calls.setdefault(item_id, {"call_id": "", "name": "", "arguments": ""})
            current["arguments"] = event.get("arguments", current["arguments"])
        elif event_type == "response.output_item.done":
            item = event.get("item") or {}
            if item.get("type") == "function_call":
                item_id = item.get("id", str(event.get("output_index", 0)))
                current = tool_calls.setdefault(item_id, {"call_id": "", "name": "", "arguments": ""})
                current["call_id"] = item.get("call_id", current["call_id"])
                current["name"] = item.get("name", current["name"])
                current["arguments"] = item.get("arguments", current["arguments"])
        elif event_type == "response.completed":
            for item in (event.get("response") or {}).get("output", []):
                if item.get("type") != "function_call":
                    continue
                item_id = item.get("id", str(item.get("output_index", 0)))
                current = tool_calls.setdefault(item_id, {"call_id": "", "name": "", "arguments": ""})
                current.update({
                    "call_id": item.get("call_id", current["call_id"]),
                    "name": item.get("name", current["name"]),
                    "arguments": item.get("arguments", current["arguments"]),
                })
            completed = True
        elif event_type in {"response.failed", "response.incomplete"}:
            final_response = event.get("response", {})
            error = final_response.get("error") or {}
            detail = error.get("message") or final_response.get("incomplete_details") or event_type
            raise RuntimeError(str(detail))
        elif event_type == "error":
            error = event.get("error") or event
            code = error.get("code") or error.get("type") or "stream_error"
            raise RuntimeError(f"{code}: {error.get('message', 'unknown error')}")

if not completed:
    raise RuntimeError("stream ended before response.completed")

print()
for call in tool_calls.values():
    arguments = json.loads(call["arguments"] or "{}")
    print("tool", call["call_id"], call["name"], arguments)

错误、重试与超时

情况客户端处理
连接超时单独设置连接超时,例如 10 秒;确认网络与 Base URL
读取超时文本请求可从 180 秒起设置;图像等耗时任务可设为 300 秒
408、429、5xx读取 Retry-After,并使用带随机抖动的指数退避;限制重试次数
400、401、403、404不要自动重试;先检查错误正文、鉴权头、接口路径、模型与参数
JSON · error response body
{
  "error": {
    "message": "请求参数无效",
    "type": "invalid_request_error",
    "param": "model",
    "code": "invalid_model"
  }
}
协议错误正文中的请求 ID响应头中的请求 ID
Responses无固定顶层字段x-request-id
Python · timeout and retry
import os
import random
import time

import requests

url = "https://www.yunqiai.chat/v1/responses"
headers = {"Authorization": f"Bearer {os.environ['YUNQI_API_KEY']}"}
payload = {"model": "gpt-5.5", "input": "你好", "max_output_tokens": 1024}

for attempt in range(4):
    delay = min(2 ** attempt, 8) + random.random()
    try:
        response = requests.post(url, headers=headers, json=payload, timeout=(10, 180))
    except requests.Timeout:
        if attempt == 3:
            raise
    else:
        if response.ok:
            print(response.json())
            break
        if response.status_code not in {408, 429, 500, 502, 503, 504}:
            response.raise_for_status()
        if attempt == 3:
            response.raise_for_status()
        retry_after = response.headers.get("Retry-After")
        if retry_after:
            try:
                delay = max(delay, float(retry_after))
            except ValueError:
                pass
    time.sleep(delay)

响应

JSON
{
  "id": "resp_01JY7X",
  "object": "response",
  "status": "completed",
  "model": "gpt-5.5",
  "output": [
    {
      "id": "msg_01JY7X",
      "type": "message",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "annotations": [],
          "text": "量子计算利用量子态处理信息……"
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 16,
    "output_tokens": 48,
    "total_tokens": 64
  }
}
YunQi AI 开放平台文档 · 客户接入与参数参考模型目录更新于 2026-08-06