Responses API
Endpoint: POST /v1/responses
Base URL: https://api.floxai.io
鉴权: Authorization: Bearer <your-api-key>
请求参数
必需参数
| 参数 | 类型 | 说明 |
|---|---|---|
input | string / array | 输入内容,可以是文本字符串,或包含文本、图像、文件的消息数组 |
常用可选参数
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
model | string | — | 模型 ID,如 gpt-4o、o3 |
instructions | string | — | 系统 / 开发者消息,与 previous_response_id 配合使用时不会继承上轮指令 |
previous_response_id | string | — | 上一轮响应的 ID,用于构建多轮对话 |
max_output_tokens | integer | — | 最大输出 token 数,含可见输出与推理 token |
temperature | number | 1 | 采样温度,范围 0~2,建议与 top_p 二选一调整 |
top_p | number | 1 | 核采样概率,范围 0~1,建议与 temperature 二选一调整 |
stream | boolean | false | 设为 true 时以 SSE 流式返回响应 |
store | boolean | true | 是否存储响应以供后续 API 检索 |
truncation | enum | disabled | 截断策略:auto(自动丢弃中间内容)/ disabled(超限直接报 400) |
user | string | — | 终端用户唯一标识符 |
metadata | object | — | 最多 16 个键值对,键 ≤ 64 字符,值 ≤ 512 字符 |
工具调用
| 参数 | 类型 | 说明 |
|---|---|---|
tools | array | 可调用工具列表,支持 file_search / function / web_search_preview / computer_use_preview |
tool_choice | string / object | none / auto / required 或指定工具 |
parallel_tool_calls | boolean | 是否允许并行工具调用,默认 true |
推理参数(o 系列模型)
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
reasoning.effort | enum | medium | 推理努力程度:low / medium / high |
reasoning.summary | enum | — | 推理摘要详细程度:auto / concise / detailed |
输出格式
| 参数 | 类型 | 说明 |
|---|---|---|
text.format | object | 输出格式:{"type": "text"} / {"type": "json_object"} / {"type": "json_schema", ...} |
include | array | 额外输出内容,可选值:file_search_call.results / message.input_image.image_url / computer_call_output.output.image_url |
延迟层
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
service_tier | enum | auto | auto / default / flex |
请求示例
curl --location --request POST 'https://api.floxai.io/v1/responses' \
--header 'Authorization: Bearer <your-api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-4.1",
"input": "Tell me a three sentence bedtime story about a unicorn."
}'响应示例
{
"id": "resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b",
"object": "response",
"created_at": 1741476542,
"status": "completed",
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"model": "gpt-4.1-2025-04-14",
"output": [
{
"type": "message",
"id": "msg_67ccd2bf17f0819081ff3bb2cf6508e60bb6a6b452d3795b",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "In a peaceful grove beneath a silver moon...",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 36,
"input_tokens_details": {"cached_tokens": 0},
"output_tokens": 87,
"output_tokens_details": {"reasoning_tokens": 0},
"total_tokens": 123
},
"temperature": 1.0,
"top_p": 1.0,
"tool_choice": "auto",
"tools": [],
"truncation": "disabled",
"store": true,
"parallel_tool_calls": true,
"reasoning": {"effort": null, "summary": null},
"metadata": {}
}响应字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 本次响应的唯一标识符 |
object | string | 固定为 response |
created_at | number | 创建时间(Unix 时间戳) |
status | enum | completed / failed / in_progress / incomplete |
output | array | 模型生成的内容项数组,建议通过 SDK 的 output_text 属性访问聚合文本 |
output_text | string | SDK 便利属性,聚合 output 中所有文本(Python / JavaScript SDK 支持) |
error | object | 生成失败时的错误对象,含 code 和 message |
incomplete_details | object | 响应不完整时的原因,如 max_output_tokens / content_filter |
usage.input_tokens | integer | 输入 token 数 |
usage.output_tokens | integer | 输出 token 数 |
usage.total_tokens | integer | 总 token 数 |