Amux
文本OpenAI 格式

Responses

OpenAI Responses API — 创建模型响应,支持多轮对话、工具调用、推理输出

OpenAI Responses API 用于创建模型响应,支持多轮对话、工具调用、推理输出等能力。相比 Chat Completions,Responses 提供更易用的多轮 / 工具状态管理(通过 previous_response_id 串联)。

项目
请求方法POST
请求路径/v1/responses
完整 URLhttps://api.amux.ai/v1/responses
认证方式Authorization: Bearer <API_TOKEN>
请求格式application/json
响应格式JSON 或 SSE(stream=true 时)

Responses 是 OpenAI 推出的新一代统一接口,集成了 Chat Completions 与 Assistants API 的能力。如果您的项目仍在使用 Chat Completions,可继续使用 /v1/chat/completions

请求体参数

Prop

Type

透传策略:amux-api 对未在上方列出的字段会原样透传至上游。未传值时由上游模型自行使用其默认值。当前版本 background(后台任务模式)尚未支持,即使传入也会被忽略。

InputItem 结构

input 为数组时,每个元素可为消息或工具调用结果:

Prop

Type

请求示例

curl https://api.amux.ai/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $AMUX_API_KEY" \
  -d '{
    "model": "gpt-5.4",
    "input": "用一句话介绍 Amux API。",
    "instructions": "You are a concise assistant."
  }'
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.amux.ai/v1",
    api_key=os.environ["AMUX_API_KEY"],
)

response = client.responses.create(
    model="gpt-5.4",
    input="用一句话介绍 Amux API。",
    instructions="You are a concise assistant.",
)

print(response.output_text)
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.amux.ai/v1',
  apiKey: process.env.AMUX_API_KEY,
});

const response = await client.responses.create({
  model: 'gpt-5.4',
  input: '用一句话介绍 Amux API。',
  instructions: 'You are a concise assistant.',
});

console.log(response.output_text);

响应示例

{
  "id": "resp_xxx",
  "object": "response",
  "created_at": 1730000000,
  "status": "completed",
  "model": "gpt-5.4",
  "output": [
    {
      "type": "message",
      "id": "msg_xxx",
      "status": "completed",
      "role": "assistant",
      "content": [
        { "type": "output_text", "text": "Amux API 是一个统一、稳定的企业级大模型接口网关。" }
      ]
    }
  ],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 18,
    "total_tokens": 42,
    "prompt_tokens_details": { "cached_tokens": 0 },
    "completion_tokens_details": { "reasoning_tokens": 0 }
  }
}

响应字段

Prop

Type

OpenAI 官方 SDK(如 Python)通常会暴露便捷属性 response.output_text,由 SDK 自行从 output[].content[] 中拼接 output_text 部件得到。该属性是 SDK 客户端逻辑,并非由 amux-api 在 JSON 中直接返回的字段。如需获取纯文本,请遍历 output[].content[]type === "output_text" 的部件。

流式响应

stream=true 时返回 SSE 事件序列,每个事件包含 event:data: 两行:

event: response.created
data: {"type":"response.created","response":{"id":"resp_xxx","status":"in_progress",...}}

event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":"Amux"}

event: response.output_text.delta
data: {"type":"response.output_text.delta","delta":" API"}

event: response.completed
data: {"type":"response.completed","response":{...}}

常见事件:

事件名说明
response.created响应已创建(in_progress)
response.output_item.added新输出条目开始(如新的 message / function_call
response.output_item.done当前输出条目完成
response.output_text.delta文本增量
response.output_text.done当前文本块结束
response.reasoning_summary_text.delta推理摘要文本增量
response.reasoning_summary_text.done推理摘要结束
response.function_call_arguments.delta工具调用参数增量
response.function_call_arguments.done工具调用参数完成
response.completed整体响应完成
response.failed响应失败
response.error / error错误事件

错误响应

{
  "error": {
    "message": "...",
    "type": "invalid_request_error",
    "param": "input",
    "code": "invalid_value"
  }
}

错误码语义与 Chat Completions 一致。

On this page