Gateway 可提供 OpenResponses 兼容的 POST /v1/responses 端点,默认禁用。

端点

  • POST /v1/responses(同 Gateway 端口,WS + HTTP 复用)

认证、安全边界、agent 路由与 gateway-openai-http-api 完全一致。

启用/禁用

{ gateway: { http: { endpoints: { responses: { enabled: true } } } } }

请求格式(支持字段)

  • input:字符串或 item 对象数组
  • instructions:合并到系统提示
  • tools:客户端工具定义(function tools)
  • tool_choice:过滤或要求客户端工具
  • stream:启用 SSE 流式
  • max_output_tokens:尽力输出限制
  • temperature / top_p:尽力采样参数
  • user:稳定会话路由
  • previous_response_id:复用之前的响应会话

Input Items

  • message:角色 system/developer/user/assistant
  • function_call_output:发送工具结果回模型
  • input_image:支持 base64 或 URL,最大 10MB
  • input_file:支持 base64 或 URL,最大 5MB,支持 PDF(自动解析文本或光栅化)

文件内容注入系统提示,标记为不可信外部内容(<<<EXTERNAL_UNTRUSTED_CONTENT>>>)。

流式(SSE)

stream: true 启用,事件类型:

  • response.created / response.in_progress
  • response.output_text.delta / response.output_text.done
  • response.completed / response.failed

文件/图片限制(可配置)

{
  gateway: { http: { endpoints: { responses: {
    enabled: true,
    maxBodyBytes: 20000000,
    maxUrlParts: 8,
    files: { allowUrl: true, maxBytes: 5242880, maxChars: 200000 },
    images: { allowUrl: true, maxBytes: 10485760 },
  }}}}
}

示例

curl -sS http://127.0.0.1:18789/v1/responses \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"model": "openclaw", "input": "hi"}'

相关