Responses 接口

文档版本: v1.0 | 更新日期: 2026-10-14

1. 接口概述

Responses 接口兼容 OpenAI Responses API 协议,与 Chat Completions 共用同一套鉴权与地址,区别只在于请求 / 返回结构:

  • 输入用 input(而非 messages),系统指令用 instructions;
  • 返回用 output[] 数组(可能同时包含推理项与文本项)。
项目值
端点POST https://api.sapis.cn/v1/responses
Content-Typeapplication/json
鉴权Authorization: Bearer sk-你的API-Key

2. 请求参数(常用)

参数类型必填说明
modelstring是模型名,如 deepseek-v4.1-flash
inputstring / array是输入内容,纯文本或消息数组
instructionsstring否系统指令(相当于 system)
streamboolean否是否流式输出,默认 false
max_output_tokensinteger否最大输出 Token 数
temperature / top_pnumber否采样参数
tools / tool_choice否工具调用

3. 调用示例

curl:

curl -X POST https://api.sapis.cn/v1/responses \
  -H "Authorization: Bearer sk-你的API-Key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash",
    "input": "用一句话介绍你自己"
  }'

Python(OpenAI SDK):

from openai import OpenAI

client = OpenAI(api_key="sk-你的API-Key", base_url="https://api.sapis.cn/v1")
resp = client.responses.create(
    model="deepseek-v4.1-flash",
    instructions="你是一个乐于助人的助手。",
    input="用一句话介绍你自己",
)
print(resp.output_text)

4. 返回结构

object 为 response,文本在 output[] 中(type 为 message 的项里),字段为 output_text:

{
  "object": "response",
  "status": "completed",
  "model": "deepseek/deepseek-v4.1-flash",
  "output": [
    { "type": "reasoning", "summary": [{ "type": "summary_text", "text": "..." }] },
    {
      "type": "message",
      "role": "assistant",
      "content": [{ "type": "output_text", "text": "hi" }]
    }
  ],
  "usage": { "prompt_tokens": 35, "completion_tokens": 15, "total_tokens": 50 }
}

5. 流式输出

设置 stream: true 后返回 SSE,事件为标准 Responses 事件,例如:

event: response.created
data: {"type":"response.created","response":{...},"sequence_number":0}

event: response.output_item.added
data: {"type":"response.output_item.added","item":{...},"sequence_number":1}

6. 注意事项

  • 平台不提供 Claude 模型,本接口用于以 Responses 协议调用平台实际支持的模型。
  • 与 Chat Completions 共用同一 Key、同一 Base URL,可随时切换。
不会配置?联系我们首次免费远程协助配置