控制台 ↗
模型详情Responses

gpt-6-astra

Responses 对话、工具调用与多模态输入

能力概览

输入

文本图片文件

输出

文本

推荐接口

Responses API

对话与推理

reasoning.effort:low、medium、high、xhigh、max。

工具调用

使用 Responses function_call / function_call_output。

图片与 PDF

图片使用 input_image,PDF 使用 input_file。

结构化输出

使用 text.format 定义 JSON Schema。

采样参数不发送 temperature、top_p、top_logprobs。

接口

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

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

文本对话也可调用 /v1/chat/completions;工具调用使用 Responses。客户端配置模型 ID 为 gpt-6-astra,Codex 的 wire_api 保持 responses。音频和视频不作为本模型的直接输入。

请求参数

参数类型说明
model必填stringgpt-6-astra
input必填string | array文本、图片、PDF 或工具结果
reasoning.effortstringlow、medium、high、xhigh、max;不发送 none 或 minimal
max_output_tokensinteger输出预算包含推理与最终回答;预算过低可能返回 incomplete
streamboolean默认 false;开启后按 SSE 事件解析
toolsarray自定义 function 工具定义
tool_choicestring | objectauto、none、required 或指定工具
text.formatobject使用 json_schema、name、schema、strict 定义结构化输出
temperature / top_p / top_logprobs不发送此型号不使用这些采样参数

请求示例

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-6-astra",
    "input": "用三句话解释量子计算",
    "max_output_tokens": 1024,
    "stream": false,
    "reasoning": {
      "effort": "low"
    }
  }'

Base64 图片输入

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

JSON · Base64
{
  "model": "gpt-6-astra",
  "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-6-astra",
    "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['YUNQIAI_API_KEY']}",
        "Content-Type": "application/json",
    },
    json=payload,
    timeout=(10, 180),
)
response.encoding = "utf-8"
if not response.ok:
    request_id = response.headers.get("x-request-id") or response.headers.get("request-id")
    raise RuntimeError(f"HTTP {response.status_code}; request_id={request_id}; body={response.text[:2000]}")
result = response.json()

if result.get("error") or result.get("status") != "completed":
    raise RuntimeError(f"File response not completed: {result.get('id')}; {result.get('status')}; {result.get('error')}; {result.get('incomplete_details')}")
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"
]
if not any(text.strip() for text in texts):
    raise RuntimeError(f"No file answer in response: {result.get('id')}")
print("\n".join(texts))
来源input_file 字段适用条件
内联 Data URLfile_data + filename本地文件可直接编码后发送
公开 URLfile_url文件地址可由服务端直接访问
文件类型处理方式建议
PDF结合提取文本与页面图像理解内容扫描件、图表较多的文档优先使用 PDF
DOCX、PPTX客户端先转换为 PDF,再使用 input_file需要版式与图表时保留页面内容
TXT、CSV、XLSX客户端提取文本或所需行列,放入 input_text明确列名与单位;不把这些文件直接套入 PDF 字段

流式输出

客户端以 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

def iter_sse_data(response):
    data_lines = []
    for line in response.iter_lines(decode_unicode=True):
        if line == "":
            if data_lines:
                data = "\n".join(data_lines)
                data_lines = []
                if data:
                    yield data
            continue
        if line.startswith(":"):
            continue
        field, _, value = line.partition(":")
        if value.startswith(" "):
            value = value[1:]
        if field == "data":
            data_lines.append(value)
    # A frame without its terminating blank line is incomplete.


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

with requests.post(
    "https://www.yunqiai.chat/v1/responses",
    headers={
        "Authorization": f"Bearer {os.environ['YUNQIAI_API_KEY']}",
        "Content-Type": "application/json",
    },
    json=payload,
    stream=True,
    timeout=(10, 180),
) as response:
    response.encoding = "utf-8"
    if not response.ok:
        request_id = response.headers.get("x-request-id") or response.headers.get("request-id")
        raise RuntimeError(f"HTTP {response.status_code}; request_id={request_id}; body={response.text[:2000]}")
    completed = False
    tool_calls = {}

    for data in iter_sse_data(response):
        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、5xx、网络超时POST 结果可能未知;记录请求 ID,不自动重放。已取得 MJ id 时只重试 GET 查询
429先区分限流与额度不足;限流按 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 · single attempt and timeout
import os
import requests

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

# A POST may have reached the server even when the client times out.
# Do not automatically replay it or switch to a different model.
response = requests.post(url, headers=headers, json=payload, timeout=(10, 180))
request_id = response.headers.get("x-request-id") or response.headers.get("request-id")
if not response.ok:
    raise RuntimeError(
        f"HTTP {response.status_code}; request_id={request_id or 'unavailable'}; "
        "check the redacted error response before starting a new request"
    )
print(response.json())

响应

JSON
{
  "id": "resp_01JY7X",
  "object": "response",
  "status": "completed",
  "model": "gpt-6-astra",
  "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-09-14 · v1.0.11