Chat Completions API
Fusion Max 和 Fusion Code 提供兼容 OpenAI 的 Chat Completions 接口。本文列出了支持的字段、响应格式和校验规则。
使用 FUMO Dashboard 的 Key,适用于线上注册与充值的账号。
| Base URL | https://capi.fumolab.ai/api/fusion/v1 |
| Endpoint | POST /chat/completions |
| Authorization | Bearer <API_KEY> |
| Content type | application/json |
请求
调用公开接口时,必须提供已授权的 model ID 和非空 messages 数组。
{
"model": "fusion-max-1.0",
"messages": [
{ "role": "system", "content": "Return a concise technical answer." },
{ "role": "user", "content": "Compare the two implementation options." }
],
"stream": true,
"temperature": 0.2
}
模型 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 的内部模型拓扑由服务配置决定。完整模型列表见快速开始。
Messages
支持标准的 system、developer、user、assistant 和 tool 角色。
数组必须至少包含一条消息。不支持的角色会在调用上游前返回 400 invalid_parameter。
content 可以是字符串,也可以是由 text、input_text 或 output_text 类型组成的文本内容数组。用户消息也可以使用标准的 image_url 图片内容:
{
"role": "user",
"content": [
{ "type": "text", "text": "Describe the architecture in this diagram." },
{
"type": "image_url",
"image_url": { "url": "https://example.com/architecture.png" }
}
]
}
暂不支持音频和文件内容。
Chat Completions 是无状态接口:每一轮都需要发送完整对话历史。
支持的请求字段
| 字段 | 行为 |
|---|---|
model | 必填;已为当前 Key 授权的模型 ID |
messages | 必填且非空;可包含文本和图片输入的对话 |
stream | 为 true 时返回 Server-Sent Events |
stream_options.include_usage | 设为 true 时,在流式响应末尾加入 usage 数据块 |
temperature | 0 到 2;用于协作生成与最终综合 |
top_p | 0 到 1;用于协作生成与最终综合 |
max_tokens、max_completion_tokens | 大于 0 的客户端输出上限;同时提供时两者必须相同 |
stop | 一个非空字符串,或由 1 到 4 个非空字符串组成的数组 |
n | 仅支持 1 |
tools | 使用 JSON Schema 参数定义的函数工具 |
tool_choice | none、auto、required 或指定函数 |
parallel_tool_calls | 控制最终响应能否同时包含多个函数调用 |
response_format | text、json_object 或 json_schema |
modalities | 如需提供,只能是 ["text"] |
functions、function_call | 旧版别名,会分别规范化为 tools 与 tool_choice |
reasoning_effort: 仅 Fusion Max 2.0 支持 low、medium、high、max,默认 medium;Max 1.0 和 Code 1.0 不支持调整 effort。
未知顶层字段会出于兼容性被接受、记录为结构化告警,并在进入执行流程前移除。
工具调用
只有 Fusion 的最终响应可以向客户端发出工具调用。中间协作过程不能执行客户端工具,也不能返回具有最终效力的调用。
{
"model": "fusion-code-1.0",
"messages": [
{
"role": "user",
"content": "Check the deployment status for service api."
}
],
"tools": [
{
"type": "function",
"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",且 function.name 不能为空。当 strict 为 true 时,必须提供 function.parameters,Fusion 会按该 Schema 校验返回的参数。
结构化输出
使用 response_format 要求返回 JSON 对象:
{
"type": "json_object"
}
也可以提供 JSON Schema:
{
"type": "json_schema",
"json_schema": {
"name": "review",
"schema": {
"type": "object",
"properties": {
"approved": { "type": "boolean" },
"reason": { "type": "string" }
},
"required": ["approved", "reason"],
"additionalProperties": false
}
}
}
Fusion 会在返回前根据指定契约校验完整的最终文本,不会从前后夹杂的说明文字中提取 JSON。
流式响应
当 stream: true 时,Fusion 使用 chat.completion.chunk 帧返回 text/event-stream。
一次成功的流式响应依次包含:
assistant角色帧、可选的delta.reasoning_content,以及正文增量或经过校验的工具调用增量;纯工具调用响应可能没有正文增量;- 带有
finish_reason的结束项; - 当
stream_options.include_usage为true时,一个choices为空数组、仅包含usage的数据块; data: [DONE]。
finish_reason 可能是 stop、length 或 tool_calls。
结构化输出、显式输出上限、停止序列和必选工具调用可能需要先缓冲,待校验完成后再释放内容。工具调用参数也会在完整校验后再发送。
响应
非流式成功响应遵循标准 Chat Completions 结构:
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1785200000,
"model": "fusion-max-1.0",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 120,
"completion_tokens": 48,
"total_tokens": 168
}
}
客户端应依赖以上标准 Token 字段。随着服务演进,额外的 usage 元数据可能发生变化。
不支持的字段与接口
当前请求契约不支持:
- 音频或文件输入;
- 大于 1 的
n; frequency_penalty、presence_penalty、logit_bias,或确定性的seed语义;logprobs或top_logprobs;store、metadata、prediction、prompt_cache_options、prompt_cache_retention、safety identifier、用户追踪、Web Search 或 moderation 扩展。
语法有效但未支持的参数会被记录为结构化告警,并在执行前移除。无效值、相互冲突的控制参数和未支持的内容类型仍会导致校验错误。prompt_cache_key 可作为传输层的请求亲和性提示,但不能用于配置模型侧的 Prompt Cache。
其他不支持的接口包括:
- Anthropic Messages;
- 旧版文本 Completions;
- Embeddings、Images 或 Audio 接口。
错误
空 messages 数组等无效请求会返回 400 和 code: "invalid_parameter"。具体 message 和 error envelope 可能因网关而异:
{
"error": {
"message": "...",
"type": "invalid_request_error",
"code": "invalid_parameter",
"param": "messages"
},
"request_id": "..."
}
| 状态码 | 含义 |
|---|---|
400 | JSON 格式错误、参数无效或 Schema 无效 |
401 | API Key 缺失、格式错误或无效 |
403 | 当前 API Key 无权使用所请求的模型或 Fusion 服务 |
404 | 路由或模型别名不存在 |
429 | 达到模型并发上限或其他请求限制 |
501 | 请求的接口尚未实现 |
502 | Fusion 或上游生成依赖失败 |
503 | 鉴权服务或其他网关依赖不可用 |
联系 FUMO Lab 支持团队时,请提供响应中的 request_id。
模型能力
三款模型均支持文本/图片输入、文本/工具调用输出,以及 Chat Completions 和 Responses。文件由 Agent 读取,不支持原生文件上传。
仅 Fusion Max 2.0 支持 low、medium、high、max,默认 medium;Max 1.0 和 Code 1.0 不支持调整 effort。
