Responses API
Fusion Max 和 Fusion Code 提供兼容 OpenAI 的 Responses API,适用于多模态和 Coding Agent 任务。接口采用无状态设计,支持的字段和功能见下文。
使用 FUMO Dashboard 的 Key,适用于线上注册与充值的账号。
| Base URL | https://capi.fumolab.ai/api/fusion/v1 |
| Endpoint | POST /responses |
| Authorization | Bearer <API_KEY> |
| Content type | application/json |
请求
请求需要包含已授权的 model ID,以及非空字符串或数组形式的 input。以下示例还请求自动生成推理摘要:
{
"model": "fusion-code-1.0",
"instructions": "Act as a precise software engineering agent.",
"input": "Inspect the proposed migration and identify the highest-risk change.",
"reasoning": {
"summary": "auto"
},
"text": {
"verbosity": "medium"
},
"stream": true
}
模型 ID 与核心路由
| 产品 | 已授权模型 ID | 适用场景 |
|---|---|---|
| Fusion Max 2.0 | fusion-max-2.0 | 高性能编码、智能体和文档分析,兼顾成本效率。 |
| Fusion Max 1.0 | fusion-max-1.0 | 复杂推理、研究与高要求的 Agent 工作负载 |
| Fusion Code 1.0 | fusion-code-1.0 | 编程、调试、终端任务与软件 Agent 工作流 |
请求必须提供已为当前 Key 授权的模型 ID。Fusion Max 和 Fusion Code 的内部模型拓扑由服务配置决定。完整模型列表见快速开始。
Input
单轮用户输入可以直接传字符串:
{
"input": "Review this implementation plan."
}
多轮对话需要在每次请求中发送完整的 input 数组:
{
"input": [
{
"type": "message",
"role": "user",
"content": [{ "type": "input_text", "text": "Propose a safe migration." }]
},
{
"type": "message",
"role": "assistant",
"content": [
{ "type": "output_text", "text": "First, add compatibility tests." }
]
},
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "Turn that into an implementation sequence."
}
]
}
]
}
消息角色可以是 system、developer、user 或 assistant。内容可以是字符串,也可以是由 text、input_text、output_text 或 input_image 类型组成的数组。图片通过 input_image.image_url 提供:
{
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "What changed between these diagrams?"
},
{
"type": "input_image",
"image_url": "https://example.com/architecture-v2.png",
"detail": "auto"
}
]
}
]
}
暂不支持音频和文件输入。
支持的请求字段
| 字段 | 行为 |
|---|---|
model | 必填;已为当前 Key 授权的模型 ID |
input | 必填;字符串或包含文本、图片内容的非空 input 数组 |
instructions | 添加到请求开头的 developer 级指令 |
stream | 为 true 时返回 Responses Server-Sent Events |
temperature | 0 到 2 |
top_p | 0 到 1 |
max_output_tokens | 大于 0 的客户端输出上限 |
reasoning.effort | 仅 Fusion Max 2.0 支持 low、medium、high、max,默认 medium;Max 1.0 和 Code 1.0 不支持调整 effort。 |
reasoning.summary | auto、concise 或 detailed |
text.verbosity | low、medium 或 high |
text.format | text、json_object 或 json_schema |
tools | 由客户端执行的 function 和 custom/freeform 工具 |
input[0].additional_tools | Responses Lite 中单个前置 developer 项的工具 |
tool_choice | none、auto、required 或指定 function/custom 工具 |
parallel_tool_calls | 控制最终响应能否同时包含多个工具调用 |
service_tier | 当所选路由支持对应字段时,作为最终生成阶段的提示参数 |
store | 省略或设为 false;不支持由上游服务商存储响应 |
未知顶层字段会出于兼容性被接受、记录为结构化告警,并在进入执行流程前移除。
仅 Fusion Max 2.0 支持 low、medium、high、max,默认 medium;Max 1.0 和 Code 1.0 不支持调整 effort。
客户端工具
Fusion 同时支持有 JSON Schema 约束的 function 工具,以及接收自由文本输入的 custom 工具。工具由客户端执行,Fusion 不会在服务端代为运行。
Function 工具
Responses 的函数工具直接将函数信息放在 tool 对象中:
{
"model": "fusion-code-1.0",
"input": "Check the deployment status for service api.",
"tools": [
{
"type": "function",
"name": "get_deployment_status",
"description": "Return the current deployment status for a service.",
"parameters": {
"type": "object",
"properties": {
"service": { "type": "string" }
},
"required": ["service"],
"additionalProperties": false
},
"strict": true
}
],
"tool_choice": "auto"
}
函数调用会以 type: "function_call" 的输出项返回。执行函数后,在下一次请求中同时发送原函数调用与执行结果,继续生成最终响应:
{
"input": [
{
"type": "function_call",
"call_id": "call_123",
"name": "get_deployment_status",
"arguments": "{\"service\":\"api\"}"
},
{
"type": "function_call_output",
"call_id": "call_123",
"output": "{\"status\":\"healthy\"}"
}
]
}
只有 Fusion 的最终响应可以向客户端发出具有最终效力的工具调用;中间协作过程不能执行客户端工具。
Custom/freeform 工具
当工具需要接收自由文本而不是 JSON 参数时,使用 type: "custom":
{
"input": "Prepare and apply the smallest safe patch.",
"tools": [
{
"type": "custom",
"name": "apply_patch",
"description": "Apply a patch expressed in unified diff format."
}
],
"tool_choice": "auto"
}
响应会返回带有自由文本 input 的 custom_tool_call 输出项。继续无状态调用循环时,使用相同的 call_id 回传对应的 custom_tool_call_output。
Responses Lite additional_tools
Responses Lite 只接受位于 input[0] 的单个前置 developer 项携带 additional_tools。这些定义会与顶层 tools 合并;完整 JSON 相同的定义会去重,同名但定义不同的工具会被拒绝。
{
"input": [
{
"type": "message",
"role": "developer",
"content": [
{ "type": "input_text", "text": "Use the available repository tools." }
],
"additional_tools": [
{
"type": "custom",
"name": "shell",
"description": "Run a shell command and return its output."
}
]
},
{
"type": "message",
"role": "user",
"content": [
{
"type": "input_text",
"text": "Inspect the repository and run the relevant checks."
}
]
}
]
}
additional_tools 是 Fusion Responses Lite 扩展,不属于 OpenAI Responses 标准字段。它出现在其他 input 项中,或出现在多个 developer 前缀中时,请求会被拒绝。
结构化输出
通过 text.format 请求 JSON 输出:
{
"text": {
"format": {
"type": "json_schema",
"name": "review",
"strict": true,
"schema": {
"type": "object",
"properties": {
"approved": { "type": "boolean" },
"reason": { "type": "string" }
},
"required": ["approved", "reason"],
"additionalProperties": false
}
}
}
}
Fusion 会在返回前,根据指定格式校验完整的最终文本。
流式响应
当 stream: true 时,Fusion 使用标准 Responses 事件名称。一次成功的文本流可能依次包含:
response.created;- 可选的 reasoning summary 事件;
response.output_item.added;response.output_text.delta、函数调用参数事件或 custom 工具输入事件;response.output_item.done;response.completed。
流以 response.completed 或 response.failed 结束。Responses 流不使用 Chat Completions 的 data: [DONE] 标记。
响应
非流式文本响应使用 Responses 响应对象的结构:
{
"id": "resp_fusion_...",
"object": "response",
"status": "completed",
"model": "fusion-code-1.0",
"output": [
{
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "...",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 120,
"output_tokens": 48,
"total_tokens": 168
}
}
如果生成因 max_output_tokens 停止,响应及已保留的输出项会使用 status: "incomplete",并返回 incomplete_details.reason: "max_output_tokens"。
无状态兼容范围
Fusion 不存储 Responses 响应对象。每次请求都需要携带完整的对话与工具历史。
以下 OpenAI Responses 能力不受支持:
previous_response_id和conversation;store: true、后台执行,以及读取由上游服务商保存的响应;- Web Search、File Search、Computer Use、Code Interpreter 等托管工具;
- 音频和文件输入;
include、truncation和metadata;
语法有效但未支持的字段会被记录为结构化告警,并在执行前移除。include: [] 和 include: ["reasoning.encrypted_content"] 可作为兼容性提示被接受,但 Fusion 只返回公开推理摘要,不返回加密推理。字段类型错误或无效工具定义仍会导致校验错误。
需要执行客户端动作时,请使用 function 或 custom/freeform 工具。
SDK 示例
import os
from openai import OpenAI
client = OpenAI(
base_url="https://capi.fumolab.ai/api/fusion/v1",
api_key=os.environ["FUMO_API_KEY"],
)
response = client.responses.create(
model="fusion-code-1.0",
input="Review the repository and propose the smallest safe change.",
)
print(response.output_text)
错误
校验错误会指出 Responses API 对外字段,例如 max_output_tokens 或 text.verbosity,并使用 code: "invalid_parameter"。JSON 格式或请求字段类型无法解析时使用 code: "invalid_json"。语法有效但未支持的字段会被记录为结构化告警后忽略,而不是直接拒绝。
配置 Codex · 使用 Chat Completions
模型能力
三款模型均支持文本/图片输入、文本/工具调用输出,以及 Chat Completions 和 Responses。文件由 Agent 读取,不支持原生文件上传。
仅 Fusion Max 2.0 支持 low、medium、high、max,默认 medium;Max 1.0 和 Code 1.0 不支持调整 effort。
