Bypass OpenAI Responses 响应
原厂协议与认证
使用 XHub 公开模型名及虚拟密钥;部署必须启用对应 Bypass 协议。网关替换上游模型名并注入部署凭据,保留原厂扩展字段,同时执行权限和计费;Bypass 不执行标准入口的调用前文本护栏链。客户端发送 Authorization: Bearer $XHUB_API_KEY。模型支持由部署决定,不表示所有原厂模型自动可用。
接口概述
Responses 响应
Responses 响应
接口行为
读取 output[].content,output_text 是 SDK 便利属性,不保证在原始 JSON 中。创建不意味着支持查询或取消路由。
接口与认证
POST /bypass/openai/v1/responses使用 XHub API 密钥:Authorization: Bearer 。不要把供应商密钥当作网关密钥。
Base URL 使用调试台显示的网关根地址,不额外追加 /v1;实际请求使用上面的完整接口路径。
请求示例
curl "$XHUB_BASE_URL/bypass/openai/v1/responses" \
-H "Authorization: Bearer $XHUB_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"YOUR_MODEL_NAME","input":"Hello, introduce yourself."}'请求参数
| 字段 | 类型 | 说明 |
|---|---|---|
| model | string · required | 公开模型名,部署必须支持此协议。 |
| input | string or array · required | 文本或带类型的输入项。 |
| instructions | string | 系统指令。 |
| max_output_tokens | integer | 输出上限。 |
| stream | boolean | 支持时返回带类型 SSE。 |
| tools / tool_choice | array / string or object | 仅上游支持的工具。 |
| previous_response_id | string | 需要上游状态支持。 |
成功响应
{
"id": "resp-example",
"object": "response",
"status": "completed",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Hello!"
}
]
}
],
"usage": {
"input_tokens": 10,
"output_tokens": 5,
"total_tokens": 15
}
}| 字段 | 类型 |
|---|---|
| id | string |
| object | string |
| status | string |
| output | object[] |
| output[].type | string |
| output[].role | string |
| output[].content | object[] |
| output[].content[].type | string |
| output[].content[].text | string |
| usage | object |
| usage.input_tokens | number |
| usage.output_tokens | number |
| usage.total_tokens | number |
错误与排查
| HTTP | 说明 |
|---|---|
| 400 | 请求无效,请检查 JSON、参数和查询。 |
| 401 | XHub 凭据缺失或无效。 |
| 403 | 权限拒绝,请检查模型范围或策略。 |
| 429 | 超过限制,请检查响应详情与 Retry-After。 |