Responses 响应
接口行为
POST /responses 是别名。读取 output[].content,output_text 是 SDK 便利属性,不保证在原始 JSON 中。创建不意味着支持查询或取消路由。
接口与认证
POST /v1/responses使用 XHub API 密钥:Authorization: Bearer 。不要把供应商密钥当作网关密钥。
Base URL 使用调试台显示的网关根地址,不额外追加 /v1;实际请求使用上面的完整接口路径。
请求示例
curl "$XHUB_BASE_URL/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 | 使用网关历史并固定原部署,按调用方、请求模型和端点隔离,保留一小时。上下文缺失或过期拒绝续接,instructions 不继承。 |
成功响应
{
"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。 |