POST

Authorizations

Authorization
string
header
required

在请求头中传入:Authorization: Bearer sk-...

Body

application/json

OpenAI Chat Completions 兼容请求。可承载普通对话、流式输出、图文理解、工具调用和结构化输出。

model
string
required

要调用的模型 ID。先用 GET /v1/models 获取当前 Key 可访问的模型。

messages
object[]
required

对话消息数组。常见 role 包括 system、user、assistant、tool。图文输入时,content 由文本和 image_url 内容块组成。

stream
boolean
default:false

是否开启流式返回。true 时响应为 text/event-stream,客户端按 SSE 逐段读取。

temperature
number

采样温度。低值输出更确定,高值输出更发散。

Required range: 0 <= x <= 2
max_tokens
integer

本次生成 token 上限。部分新模型改用 max_completion_tokens。

max_completion_tokens
integer

新模型常用的输出 token 上限字段。是否与 max_tokens 同时提交,以模型说明为准。

tools
object[]

工具定义数组。函数工具通常包含 type=function、function.name、function.description 和参数 schema。

tool_choice

工具选择策略。可填 auto、none、required,或指定某个函数工具。

response_format
object

输出格式控制。JSON 模式或 JSON Schema 结构化输出会读取该字段。

reasoning_effort
string

推理模型的推理强度,例如 low、medium、high。是否生效以模型说明为准。

extra_body
object

模型扩展参数容器。部分图片聊天模型使用 Chat Completions 时,画幅和图片档位可放在模型约定的扩展字段中。

aspect_ratio
string

图片聊天模型的顶层兼容字段。若同时传 nested image_config,nested 值优先。

Example:

"16:9"

image_size
string

图片聊天模型的顶层兼容字段。若同时传 nested image_config,nested 值优先。

Example:

"2K"

resolution
string

图片聊天模型的顶层兼容字段。部分模型会将该字段作为 image_size 的别名处理;image_size 和 nested image_config 的优先级更高。

Example:

"4K"

Response

补全结果。流式请求返回 text/event-stream。

id
string
object
string
created
integer
model
string
choices
object[]
usage
object