Responses
更新时间: 2026/09/02 18:26:43
AIHub 在 https://ai.yunxinapi.com/hub/v1 下支持 OpenAI Responses 兼容入口。
Responses 用于更统一的 OpenAI 新式响应格式。调用方式与 OpenAI SDK 的自定义 base URL 模式一致,模型名使用 AIHub 逻辑模型。具体可用字段仍取决于所选模型、渠道和上游协议能力。
请求 URL
POST https://ai.yunxinapi.com/hub/v1/responsesPOST https://ai.yunxinapi.com/hub/v1/responses/compact
https://ai.yunxinapi.com/hub/v1/responses 支持非流式和流式;https://ai.yunxinapi.com/hub/v1/responses/compact 当前仅支持非流式。
请求头
| Header | 必填 | 说明 |
|---|---|---|
Authorization |
是 | AIHub 访问令牌,格式为 Bearer <AIHUB_TOKEN> |
Content-Type |
是 | 固定使用 application/json |
/v1/responses 请求体
核心参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model |
string | 是 | AIHub 模型名称,用于模型授权、限流、路由选择和上游模型映射。 |
-
input |
string/object[] | 否 | 用户输入,可为纯文本或 Responses input item 数组。 |
type |
string | 是 | 输入项类型:message、input_text、input_image、input_file。 |
role |
string | 否 | message 类型的角色:user、assistant。 |
content |
string/object[] | 否 | message 类型的内容。 |
text |
string | 否 | input_text 的文本内容。 |
image_url |
string | 否 | input_image 的图片 URL 或 data URL。 |
file_url |
string | 否 | input_file 的文件 URL。 |
detail |
string | 否 | 图片细节等级,仅 input_image 有效。 |
instructions |
string | 否 | 系统/开发者级指令。 |
max_output_tokens |
int | 否 | 最大输出 token 数。 |
stream |
bool | 否 | 是否启用 SSE 流式输出,true 时请求模式为流式。 |
stream_options |
object | 否 | 流式选项,如 include_usage;include_obfuscation 默认会被过滤,需渠道允许。 |
tools |
object[] | 否 | 工具定义数组(MCP、function、web search 等具体类型取决于上游)。 |
tool_choice |
string/object | 否 | 工具选择策略。 |
输出与推理控制
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
text |
object | 否 | 文本输出配置,如 format JSON Schema。 |
reasoning |
object | 否 | 推理配置,如 effort、summary。 |
temperature |
number | 否 | 随机性控制。 |
top_p |
number | 否 | nucleus sampling 参数。 |
top_logprobs |
int | 否 | 返回候选 token logprob 数,需模型支持。 |
include |
string[] | 否 | 额外包含的响应内容路径,支持情况取决于上游。 |
parallel_tool_calls |
bool | 否 | 是否允许并行工具调用。 |
max_tool_calls |
int | 否 | 最大工具调用次数。 |
truncation |
string/object | 否 | 上下文截断策略。 |
会话与扩展参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
metadata |
object | 否 | 客户侧元数据。 |
previous_response_id |
string | 否 | 上一轮 response ID,用于连续会话。 |
conversation |
string/object | 否 | Responses 会话对象或会话 ID。 |
context_management |
object | 否 | 上下文管理配置。 |
store |
bool | 否 | 是否允许上游存储请求/响应数据。渠道配置可禁用该字段透传。 |
service_tier |
string | 否 | 上游服务层级。默认会被过滤,需渠道允许后才透传。 |
safety_identifier |
string | 否 | 安全风控用户标识。默认会被过滤,需渠道允许后才透传。 |
prompt_cache_key |
string | 否 | 上游 prompt cache 复用键。 |
prompt_cache_retention |
string/object | 否 | 上游 prompt cache 保留策略。 |
user |
string/object | 否 | 终端用户标识。 |
prompt |
object | 否 | OpenAI Prompt 对象或 prompt 引用。 |
enable_thinking |
bool/object | 否 | 部分 Qwen 等模型的思考模式开关。 |
preset |
string/object | 否 | 部分 Perplexity 等上游的预设参数。 |
/v1/responses/compact 请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model |
string | 是 | AIHub 逻辑模型名。当前 AIHub 仅强校验该字段。 |
| 其他字段 | object | 否 | 按上游 Responses Compact 合同透传;当前接口不支持流式。 |
请求示例
bashcurl "https://ai.yunxinapi.com/hub/v1/responses" \
-H "Authorization: Bearer $AIHUB_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "'"$AIHUB_MODEL"'",
"instructions": "You are concise.",
"input": "Write one sentence about Aihub.",
"max_output_tokens": 128
}'
成功响应
非流式响应默认保持 OpenAI Responses 格式。
| 字段 | 类型 | 说明 |
|---|---|---|
id |
string | Response ID。 |
object |
string | 对象类型。 |
created_at |
int | Unix 秒级创建时间。 |
model |
string | 实际响应模型名,可能为上游模型名。 |
output |
object[] | 输出项列表。 |
output[].type |
string | 输出项类型:message、function_call。 |
output[].status |
string | 输出项状态。 |
output[].role |
string | 消息角色。 |
output[].content |
object[] | 消息内容块。 |
output[].call_id |
string | 工具调用 ID。 |
output[].name |
string | 工具名称。 |
output[].arguments |
string | 工具调用参数。 |
usage |
object | token 用量,通常包含 input_tokens、output_tokens、total_tokens。 |
上游厂商参数映射
https://ai.yunxinapi.com/hub/v1/responses 是 OpenAI Responses 兼容入口。AIHub 先通过 model 选择逻辑模型和渠道,再按渠道的上游模型配置将请求转发给真实厂商。
当前 Responses 能力仅在 OpenAI family 渠道上声明,非 OpenAI family 厂商不会自动将 Responses 请求转换为其原生协议。
| 目标上游/渠道类型 | 上游接口 | AIHub 入参到上游参数 | 说明 |
|---|---|---|---|
| OpenAI | POST /v1/responses |
model 映射为渠道配置的上游模型名;input、instructions、max_output_tokens、stream、tools、text 等按 OpenAI Responses 同名字段透传 |
同协议 managed 路由优先保留原始请求体,因此表中未枚举但上游支持的 OpenAI Responses 字段也可能透传 |
| Azure OpenAI | POST /openai/v1/responses |
model 会写成 Azure deployment name;input、instructions、stream、tools、text 等保持 Responses 同名字段 |
Azure v1 Responses 不走 /deployments/{deployment} 路径,部署名放在 body 的 model 字段 |
| OpenAI-compatible passthrough/OpenAI backing gateway | 通常为上游 base URL + /v1/responses |
model 先做渠道模型映射,其余字段按请求体原样进入上游 |
适合本身兼容 OpenAI Responses 的网关或厂商;字段是否生效由该上游决定 |
/v1/responses/compact |
POST /v1/responses/compact 或 Azure /openai/v1/responses/compact |
model 映射为上游模型/部署名;其他字段按 compact 合同透传 |
当前只支持非流式;必须选择支持 Responses Compact 的 OpenAI family 渠道 |
| Anthropic、Vertex、Bedrock、DeepSeek、Moonshot、Zhipu、MiniMax 等非 Responses 能力渠道 | 不适用 | 不做 Responses -> 厂商原生协议转换 | 这些厂商请使用各自已声明的 Chat Completions、Anthropic Messages 原生入口;不要假设 Responses 字段会被转换 |
常见字段对应关系:
| AIHub 字段 | OpenAI/OpenAI-compatible 上游 | Azure OpenAI 上游 | 非 OpenAI family 上游 |
|---|---|---|---|
model |
body.model,值为渠道映射后的上游模型名 |
body.model,值为 Azure deployment name |
当前 Responses 入口不路由到这些渠道 |
input |
body.input |
body.input |
不转换 |
instructions |
body.instructions |
body.instructions |
不转换 |
max_output_tokens |
body.max_output_tokens |
body.max_output_tokens |
不转换 |
stream |
body.stream,返回 OpenAI Responses SSE 事件 |
body.stream,返回 Azure/OpenAI Responses SSE 事件 |
不转换 |
tools/tool_choice |
body.tools/body.tool_choice,工具类型取决于上游 |
同名字段,能力取决于 Azure 模型 | 不转换 |
text.format |
body.text.format |
body.text.format |
不转换 |
reasoning |
body.reasoning;推理模型才生效 |
body.reasoning;模型支持才生效 |
不转换 |
store、service_tier、safety_identifier |
同名字段;可能受渠道过滤配置影响 | 同名字段;可能受渠道过滤配置影响 | 不转换 |
此文档是否对你有帮助?




