跳到主要内容

Responses API

OpenAI 兼容的 Responses API。支持推理、工具调用、网络搜索和结构化输出。

POST /v1/responses

请求示例​

curl https://gw.opentoken.io/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPEN_TOKEN_KEY" \
-d '{
"model": "gpt-4o",
"input": "人工智能的未来发展趋势是什么?",
"instructions": "你是 AI 领域的专家,请给出专业深入的分析。",
"reasoning": {"effort": "high"}
}'

请求参数​

参数类型必填默认值描述
modelstring是-模型 ID,例如 gpt-4o
inputstring / array是-用户输入文本或消息数组
instructionsstring否-系统指令,定义模型行为
max_output_tokensinteger否-限制本次响应可生成的最大输出 token 数;实际输出长度可能因停止条件、上下文长度或模型限制而更短。
temperaturenumber否1.0采样温度,用于控制生成过程中的随机性。较低的值通常会使输出更稳定、可预测;较高的值通常会增加输出的多样性。
top_pnumber否1.0核采样参数,用于将每一步采样限制在累计概率达到 top_p 的候选集合内。
toolsarray否-工具定义:function、web_search_preview、file_search
tool_choicestring / object否auto工具选择策略
textobject否-文本输出配置,可通过 format 设置结构化输出
reasoningobject否-推理配置:{"effort":"high"}
previous_response_idstring否-继续之前的对话响应
truncationstring否disabled截断策略:auto / disabled
metadataobject否-自定义元数据
streamboolean否false启用流式输出

JSON Schema 结构化输出​

{
"input": "分析这段文本的情感",
"text": {
"format": {
"type": "json_schema",
"name": "sentiment",
"schema": {
"type": "object",
"properties": {
"sentiment": {"type": "string", "enum": ["positive", "negative", "neutral"]},
"score": {"type": "number"}
},
"required": ["sentiment", "score"]
},
"strict": true
}
}
}

Tool Calling​

{
"input": "帮我查一下旧金山今天的天气",
"tools": [
{"type": "web_search_preview"},
{
"type": "function",
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"}
}
}
}
]
}

响应结构​

字段类型描述
idstring响应 ID
objectstring固定为 response
statusstring完成状态:completed、failed、in_progress
outputarray输出内容数组,每条含 type 和 content
usageobjectToken 用量统计
Copyright © 2026 OpenToken.