API 參考
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.ai/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 事件返回增量內容。