Authorization: Bearer ********************
developer
消息取代了之前的system
消息。developer
消息来实现此目的。gpt-4o
或 o3
。OpenAI 提供了多种具有不同能力、性能特征和价格 点的模型。["text"]
gpt-4o-audio-preview
模型还可以用于生成音频。要请求该模型同时生成["text", "audio"]
low
、medium
或high
。默认值为medium
。logprobs
必须设置为true
。{ "type": "json_schema", "json_schema": {...} }
启用结构化输出,确保模型将匹配您提供的 JSON 模式。更多信息请参见结构化输出指南。{ "type": "json_object" }
启用较旧的 JSON 模式,确保模型生成的消息是有效的 JSON。支持的模型建议使用 json_schema
。modalities: ["audio"]
。alloy
,ash
,ballad
,coral
,echo
,fable
,nova
,onyx
,sage
,和 shimmer
。wav
、mp3
、flac
、opus
或 pcm16
之一。o3
和 o4-mini
。message
的content
中每个输出标记的对数概率。n
保持为 1
以最小化成本。seed
和参数的重复请求应返回相同的结果。system_fingerprint
响应参数以监控后端的变化。stream: true
时设置此项。data: [DONE]
消息之前会额外流式传输一个块。该块上的 usage
字段显示整个请求的令牌使用统计信息,choices
字段将始终是一个空数组。usage
字段,但其值为 null。注意:如果流被中断,您可能无法收到包含请求总令牌使用量的最终使用块。function
。none
意味着模型不会调用任何工具,而是生成一条消息。auto
意味着模型可以选择生成消息或调用一个或多个工具。required
意味着模型必须调用一个或多个工具。{"type": "function", "function": {"name": "my_function"}}
指定特定工具,强制模型调用该工具。none
。当有工具时,默认值为 auto
。none
意味着模型不会调用任何工具,而是生成一条消息。auto
意味着模型可以选择生成消息或调用一个或多个工具。required
意味着模型必须调用一个或多个工具。tool_choice
。none
表示模型不会调用函数,而是生成一条消息。auto
表示模型可以选择生成消息或调用函数。{"name": "my_function"}
指定特定函数,强制模型调用该函数。none
。当有函数时,默认值为 auto
。none
means the model will not call a function and instead generates a message. auto
means the model can pick between generating a message or calling a function.tools
。parameters
定义一个参数列表为空的函数。top_p
,但不要同时调整两者。temperature
,但不要同时调整两者。service_tier
。{
"metadata": {
"property1": "string",
"property2": "string"
},
"temperature": 1,
"top_p": 1,
"user": "user-1234",
"service_tier": "auto",
"messages": [
{
"content": "string",
"role": "developer",
"name": "string"
}
],
"model": "string",
"modalities": [
"text"
],
"reasoning_effort": "medium",
"max_completion_tokens": 0,
"frequency_penalty": 0,
"presence_penalty": 0,
"web_search_options": {
"user_location": {
"type": "approximate",
"approximate": {
"country": "string",
"region": "string",
"city": "string",
"timezone": "string"
}
},
"search_context_size": "medium"
},
"top_logprobs": 0,
"response_format": {
"type": "text"
},
"audio": {
"voice": "string",
"format": "wav"
},
"store": false,
"stream": false,
"stop": "<|endoftext|>",
"logit_bias": null,
"logprobs": false,
"max_tokens": 0,
"n": 1,
"prediction": {
"type": "content",
"content": "string"
},
"seed": -9223372036854776000,
"stream_options": null,
"tools": [
{
"type": "function",
"function": {
"description": "string",
"name": "string",
"parameters": {},
"strict": false
}
}
],
"tool_choice": "none",
"parallel_tool_calls": true,
"function_call": "none",
"functions": [
{
"description": "string",
"name": "string",
"parameters": {}
}
]
}
curl --location --request POST 'https://api.uniapi.io/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data-raw '{
"metadata": {
"property1": "string",
"property2": "string"
},
"temperature": 1,
"top_p": 1,
"user": "user-1234",
"service_tier": "auto",
"messages": [
{
"content": "string",
"role": "developer",
"name": "string"
}
],
"model": "string",
"modalities": [
"text"
],
"reasoning_effort": "medium",
"max_completion_tokens": 0,
"frequency_penalty": 0,
"presence_penalty": 0,
"web_search_options": {
"user_location": {
"type": "approximate",
"approximate": {
"country": "string",
"region": "string",
"city": "string",
"timezone": "string"
}
},
"search_context_size": "medium"
},
"top_logprobs": 0,
"response_format": {
"type": "text"
},
"audio": {
"voice": "string",
"format": "wav"
},
"store": false,
"stream": false,
"stop": "<|endoftext|>",
"logit_bias": null,
"logprobs": false,
"max_tokens": 0,
"n": 1,
"prediction": {
"type": "content",
"content": "string"
},
"seed": -9223372036854776000,
"stream_options": null,
"tools": [
{
"type": "function",
"function": {
"description": "string",
"name": "string",
"parameters": {},
"strict": false
}
}
],
"tool_choice": "none",
"parallel_tool_calls": true,
"function_call": "none",
"functions": [
{
"description": "string",
"name": "string",
"parameters": {}
}
]
}'
n
大于 1,可能有多个选项。stop
,length
,content_filter
,tool_calls
,或者如果模型调用了函数(已弃用),这将是 function_call
。service_tier
。chat.completion
。{
"id": "string",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "string",
"refusal": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": {
"name": "string",
"arguments": "string"
}
}
],
"annotations": [
{
"type": "url_citation",
"url_citation": {
"end_index": 0,
"start_index": 0,
"url": "string",
"title": "string"
}
}
],
"role": "assistant",
"function_call": {
"arguments": "string",
"name": "string"
},
"audio": {
"id": "string",
"expires_at": 0,
"data": "string",
"transcript": "string"
}
},
"logprobs": {
"content": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
],
"refusal": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
],
"top_logprobs": [
{
"token": "string",
"logprob": 0,
"bytes": [
0
]
}
]
}
]
}
}
],
"created": 0,
"model": "string",
"service_tier": "auto",
"system_fingerprint": "string",
"object": "chat.completion",
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0,
"completion_tokens_details": {
"accepted_prediction_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0,
"rejected_prediction_tokens": 0
},
"prompt_tokens_details": {
"audio_tokens": 0,
"cached_tokens": 0
}
}
}