- OpenAI
- 平台接口
- 音乐模型
- 图像模型
- MidJourney
- ideogram
- FalAI
- 即梦
- Kling
- 视频模型
response
POST
/v1/responses
Responses
请求参数
Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token示例:
Authorization: Bearer ********************
Body 参数application/json
previous_response_id
string | null
可选
model
string
可选
gpt-4o
或 o3
。reasoning
可选
One of
reasoning models.
effort
enum<string> | enum<null>
可选
枚举值:
lowmediumhigh
默认值:
medium
summary
enum<string> | enum<null>
可选
auto
、concise
或 detailed
。枚举值:
autoconcisedetailed
generate_summary
enum<string> | enum<null>
已废弃
summary
。auto
、concise
或 detailed
。枚举值:
autoconcisedetailed
max_output_tokens
integer | null
可选
instructions
string | null
可选
previous_response_id
一起使用时,之前响应中的指令不会被带入下一次响应。这使得在新响应中替换系统(或开发者)消息变得简单。text
object
可选
format
TextResponseFormatConfiguration
{ "type": "json_schema" }
enables Structured Outputs,which ensures the model will match your supplied JSON schema. Learn more in the
Structured Outputs guide.
{ "type": "text" }
with no additional options.{ "type": "json_object" }
enables the older JSON mode, whichensures the message the model generates is valid JSON. Using
json_schema
is preferred for models that support it.
tools
array[null (Tool) {4}]
可选
tool_choice
参数来指定使用哪个工具。object
File search
object
Function
object
Web search preview
object
Computer use preview
tool_choice
可选
tools
参数以了解如何指定模型可以调用的工具。One of
none
means the model will not call any tool and instead generates a message.auto
means the model can pick between generating a message or calling one ormore tools.
required
means the model must call one or more tools.枚举值:
noneautorequired
truncation
enum<string> | enum<null>
可选
auto
:如果本次响应及之前的上下文超过了模型的上下文窗口大小,模型将通过丢弃对话中间的输入项来截断响应,以适应上下文窗口。disabled
(默认):如果模型响应将超过模型的上下文窗口大小,请求将以400错误失败。枚举值:
autodisabled
默认值:
disabled
input
必需
One of
user
role.include
array[string] | null
可选
file_search_call.results
:包含文件搜索工具调用的搜索结果。message.input_image.image_url
:包含输入消息中的图片网址。computer_call_output.output.image_url
:包含计算机调用输出中的图片网址。枚举值:
file_search_call.resultsmessage.input_image.image_urlcomputer_call_output.output.image_url
parallel_tool_calls
boolean | null
可选
默认值:
true
store
boolean | null
可选
默认值:
true
metadata
object | null
Metadata
temperature
number | null
可选
top_p
,但不要同时调整两者。>= 0<= 2
默认值:
1
示例值:
1
top_p
number | null
可选
temperature
,但不要同时调整两者。>= 0<= 1
默认值:
1
示例值:
1
user
string
可选
示例值:
user-1234
service_tier
enum<string> | enum<null>
ServiceTier
service_tier
。枚举值:
autodefaultflex
默认值:
auto
示例
{
"metadata": {
"property1": "string",
"property2": "string"
},
"temperature": 1,
"top_p": 1,
"user": "user-1234",
"service_tier": "auto",
"previous_response_id": "string",
"model": "string",
"reasoning": {
"effort": "medium",
"summary": "auto",
"generate_summary": "auto"
},
"max_output_tokens": 0,
"instructions": "string",
"text": {
"format": {
"type": "text"
}
},
"tools": [
{
"type": "file_search",
"vector_store_ids": [
"string"
],
"max_num_results": 0,
"ranking_options": {
"ranker": "auto",
"score_threshold": 0
},
"filters": {
"type": "eq",
"key": "string",
"value": "string"
}
}
],
"tool_choice": "none",
"truncation": "disabled",
"input": "string",
"include": [
"file_search_call.results"
],
"parallel_tool_calls": true,
"store": true,
"stream": false
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.uniapi.io/v1/responses' \
--header 'Content-Type: application/json' \
--data-raw '{
"metadata": {
"property1": "string",
"property2": "string"
},
"temperature": 1,
"top_p": 1,
"user": "user-1234",
"service_tier": "auto",
"previous_response_id": "string",
"model": "string",
"reasoning": {
"effort": "medium",
"summary": "auto",
"generate_summary": "auto"
},
"max_output_tokens": 0,
"instructions": "string",
"text": {
"format": {
"type": "text"
}
},
"tools": [
{
"type": "file_search",
"vector_store_ids": [
"string"
],
"max_num_results": 0,
"ranking_options": {
"ranker": "auto",
"score_threshold": 0
},
"filters": {
"type": "eq",
"key": "string",
"value": "string"
}
}
],
"tool_choice": "none",
"truncation": "disabled",
"input": "string",
"include": [
"file_search_call.results"
],
"parallel_tool_calls": true,
"store": true,
"stream": false
}'
返回响应
🟢200成功
application/json
Body
metadata
object | null
Metadata
temperature
number | null
可选
top_p
,但不要同时调整两者。>= 0<= 2
默认值:
1
示例值:
1
top_p
number | null
可选
temperature
,但不要同时调整两者。>= 0<= 1
默认值:
1
示例值:
1
user
string
可选
示例值:
user-1234
service_tier
enum<string> | enum<null>
ServiceTier
service_tier
。枚举值:
autodefaultflex
默认值:
auto
previous_response_id
string | null
可选
model
string
可选
gpt-4o
或 o3
。reasoning
可选
One of
reasoning models.
effort
enum<string> | enum<null>
可选
枚举值:
lowmediumhigh
默认值:
medium
summary
enum<string> | enum<null>
可选
auto
、concise
或 detailed
。枚举值:
autoconcisedetailed
generate_summary
enum<string> | enum<null>
已废弃
summary
。auto
、concise
或 detailed
。枚举值:
autoconcisedetailed
max_output_tokens
integer | null
可选
instructions
string | null
可选
previous_response_id
一起使用时,之前响应中的指令不会被带入下一次响应。这使得在新响应中替换系统(或开发者)消息变得简单。text
object
可选
format
TextResponseFormatConfiguration
{ "type": "json_schema" }
enables Structured Outputs,which ensures the model will match your supplied JSON schema. Learn more in the
Structured Outputs guide.
{ "type": "text" }
with no additional options.{ "type": "json_object" }
enables the older JSON mode, whichensures the message the model generates is valid JSON. Using
json_schema
is preferred for models that support it.
tools
array[null (Tool) {4}]
可选
tool_choice
参数来指定使用哪个工具。object
File search
object
Function
object
Web search preview
object
Computer use preview
tool_choice
可选
tools
参数以了解如何指定模型可以调用的工具。One of
none
means the model will not call any tool and instead generates a message.auto
means the model can pick between generating a message or calling one ormore tools.
required
means the model must call one or more tools.枚举值:
noneautorequired
truncation
enum<string> | enum<null>
可选
auto
:如果本次响应及之前的上下文超过了模型的上下文窗口大小,模型将通过丢弃对话中间的输入项来截断响应,以适应上下文窗口。disabled
(默认):如果模型响应将超过模型的上下文窗口大小,请求将以400错误失败。枚举值:
autodisabled
默认值:
disabled
id
string
必需
object
enum<string>
必需
response
。枚举值:
response
status
enum<string>
可选
completed
(已完成)、failed
(失败)、in_progress
(进行中)或 incomplete
(未完成)之一。枚举值:
completedfailedin_progressincomplete
created_at
number
必需
error
object | null
ResponseError
code
enum<string>
ResponseErrorCode
枚举值:
server_errorrate_limit_exceededinvalid_promptvector_store_timeoutinvalid_imageinvalid_image_formatinvalid_base64_imageinvalid_image_urlimage_too_largeimage_too_smallimage_parse_errorimage_content_policy_violationinvalid_image_modeimage_file_too_largeunsupported_image_media_typeempty_image_filefailed_to_download_imageimage_file_not_found
message
string
错误描述
incomplete_details
object | null
必需
reason
enum<string>
可选
枚举值:
max_output_tokenscontent_filter
output
array[null (OutputItem) {6}]
必需
output
数组中项目的长度和顺序取决于模型的响应。output
数组中的第一个项目并假设它是模型生成内容的 assistant
消息,不如在支持的 SDK 中考虑使用 output_text
属性。object
Output message
object
File search tool call
object
Function tool call
object
Web search tool call
object
Computer tool call
object
Reasoning
output_text
string | null
可选
output
数组中所有 output_text
项的聚合文本输出(如果存在)。usage
object
ResponseUsage
input_tokens
integer
输入令牌的数量。
input_tokens_details
object
必需
output_tokens
integer
输出令牌的数量。
output_tokens_details
object
必需
total_tokens
integer
使用的令牌总数。
parallel_tool_calls
boolean
必需
默认值:
true
示例
{
"metadata": {
"property1": "string",
"property2": "string"
},
"temperature": 1,
"top_p": 1,
"user": "user-1234",
"service_tier": "auto",
"previous_response_id": "string",
"model": "string",
"reasoning": {
"effort": "medium",
"summary": "auto",
"generate_summary": "auto"
},
"max_output_tokens": 0,
"instructions": "string",
"text": {
"format": {
"type": "text"
}
},
"tools": [
{
"type": "file_search",
"vector_store_ids": [
"string"
],
"max_num_results": 0,
"ranking_options": {
"ranker": "auto",
"score_threshold": 0
},
"filters": {
"type": "eq",
"key": "string",
"value": "string"
}
}
],
"tool_choice": "none",
"truncation": "disabled",
"id": "string",
"object": "response",
"status": "completed",
"created_at": 0,
"error": {
"code": "server_error",
"message": "string"
},
"incomplete_details": {
"reason": "max_output_tokens"
},
"output": [
{
"id": "string",
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "string",
"annotations": [
{
"type": "file_citation",
"file_id": "string",
"index": 0
}
]
}
],
"status": "in_progress"
}
],
"output_text": "string",
"usage": {
"input_tokens": 0,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 0,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 0
},
"parallel_tool_calls": true
}
修改于 2025-05-18 07:36:21