Skip to main content
POST
创建模型响应
请求参数和响应字段与官方 Responses API 格式保持一致。完整规范请参考 OpenAI 官方文档
此接口支持文本、图像和文件输入,以及结构化输出、工具调用、多轮对话、后台处理和流式响应。

授权

Authorization
string
header
必填

请前往 TTAPI 控制台 获取 API 密钥。

请求体

application/json

OpenAI 兼容 Responses API 的请求体。

model
string

用于生成响应的模型 ID,详见支持模型

示例:

"gpt-5.4-mini"

input

发送给模型的文本、图像或文件输入;字符串会被视为用户消息。

示例:

"请用通俗语言解释量子计算。"

instructions
string

插入模型上下文的 system 或 developer 指令。使用 previous_response_id 时不会继承上一响应的指令。

previous_response_id
string

上一条响应的 ID,用于多轮对话;不能与 conversation 同时使用。

conversation

此响应所属的对话。

background
boolean
默认值:false

是否在后台运行响应。

include
enum<string>[]

指定响应中需要额外包含的输出数据。

可用选项:
file_search_call.results,
web_search_call.results,
web_search_call.action.sources,
message.input_image.image_url,
computer_call_output.output.image_url,
code_interpreter_call.outputs,
reasoning.encrypted_content,
message.output_text.logprobs
max_output_tokens
integer

可生成的最大 token 数,包括可见输出和推理 token。

必填范围: x >= 1
max_tool_calls
integer

本次响应可处理的内置工具调用总数上限。

必填范围: x >= 1
metadata
object

附加到响应的最多 16 个字符串键值对。

parallel_tool_calls
boolean
默认值:true

是否允许模型并行调用工具。

prompt
object

可复用提示词模板及变量。

prompt_cache_key
string

用于提高提示词缓存命中率的稳定键。

prompt_cache_retention
enum<string>

提示词缓存保留策略。

可用选项:
in-memory,
24h
reasoning
object

受支持模型的推理配置。

safety_identifier
string

用于滥用检测的稳定终端用户标识。

service_tier
enum<string>
可用选项:
auto,
default,
flex,
scale,
priority
store
boolean

是否存储生成的响应,以便后续通过 API 获取。

stream
boolean
默认值:false

是否通过服务器发送事件(SSE)流式返回响应。

stream_options
object

流式响应选项,仅在 stream 为 true 时设置。

temperature
number

采样温度。通常只调整 temperature 或 top_p 其中之一。

必填范围: 0 <= x <= 2
text
object
tool_choice

控制模型可调用哪些工具。

可用选项:
none,
auto,
required
tools
object[]

提供给模型的函数工具或受支持的内置工具。

top_logprobs
integer
必填范围: 0 <= x <= 20
top_p
number
必填范围: 0 <= x <= 1
truncation
enum<string>
默认值:disabled
可用选项:
auto,
disabled

响应

请求成功。stream 为 true 时返回服务器发送事件。

id
string
必填
示例:

"resp_67ccd2bed1ec8190b14f964abc0542670bb6a6b452d3795b"

object
string
必填
Allowed value: "response"
created_at
number
必填
示例:

1741476542

status
enum<string>
必填
可用选项:
completed,
failed,
in_progress,
cancelled,
queued,
incomplete
model
string
必填
output
object[]
必填
error
object | null
incomplete_details
object | null
output_text
string
read-only

SDK 提供的聚合文本输出便捷字段。

previous_response_id
string | null
store
boolean
usage
object
metadata
object
最后修改于 2026年7月15日