Responses
使用 OpenAI Responses 风格接口创建多模态响应。
Responses API 使用 input 作为统一输入,适合新的 OpenAI Responses 风格模型,也支持流式输出、工具调用、推理配置和上下文续接。
端点
| 方法 | 路径 | 说明 |
|---|---|---|
POST | /v1/responses | 创建响应 |
POST | /v1/responses/compact | Responses 压缩接口,字段较少 |
请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 ID |
input | string 或 array | 是 | 输入内容。可包含 input_text、input_image、input_file |
instructions | string | 否 | 系统级指令 |
stream | boolean | 否 | 是否返回 SSE 流 |
max_output_tokens | integer | 否 | 最大输出 token 数 |
temperature、top_p | number | 否 | 采样参数 |
tools、tool_choice | array/object | 否 | 工具配置 |
parallel_tool_calls | boolean | 否 | 是否允许并行工具调用 |
max_tool_calls | integer | 否 | 最大工具调用次数 |
previous_response_id | string | 否 | 续接上一轮响应 |
reasoning | object | 否 | 推理配置,例如 effort、summary |
text | object | 否 | 文本输出格式配置 |
include、truncation | any | 否 | OpenAI Responses 扩展字段 |
metadata、user | any | 否 | 元数据或用户标识 |
store、service_tier、safety_identifier | any | 否 | OpenAI 扩展字段,可能受渠道设置过滤 |
curl 示例
curl https://api.tensoraxis.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TENSORAXIS_API_KEY" \
-d '{
"model": "gpt-4o",
"input": "用两句话解释什么是 API 网关"
}'多模态输入示例
{
"model": "gpt-4o",
"input": [
{
"role": "user",
"content": [
{"type": "input_text", "text": "描述这张图片"},
{"type": "input_image", "image_url": "https://example.com/image.png"}
]
}
]
}压缩接口
/v1/responses/compact 接收更小的请求体:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 ID |
input | any | 否 | 待压缩输入 |
instructions | any | 否 | 指令 |
previous_response_id | string | 否 | 上一轮响应 ID |
响应结构
响应遵循 OpenAI Responses 风格,核心字段包括 id、model、output、usage。流式响应会以 SSE 事件返回增量内容。