认证
authorization string 必填
所有 API 均使用 Bearer Token 鉴权
获取 API Key:
访问 API Key 管理页面 获取 API Key
用法:
将以下 Header 添加到请求中:
Authorization: Bearer YOUR_API_KEY
参数
model string 必填
请求使用的模型 ID
值:hy4
messages array 必填
对话历史, 最大输入为 960K token;输入与输出总量须在 1024K token 上下文窗口内
role
string必填消息角色
可选值:
system、user、assistant、tool
content
string | array | null文本字符串或由文本和图像内容块组成的数组;包含工具调用的助手消息可以使用
nulltype
string必填内容块类型
可选值:
text、image_urltext
string文本内容,
type为text时必填image_url
object图像输入,
type为image_url时必填 支持 PNG、JPEG、WEBP 和非动态图 GIF, 每张图像解码后最大为10 MB, 单次请求最多包含600张图像(含历史消息) 建议图像尺寸约为128×128至2048×2048;更大的图像会被缩小, 超过5500×5500的图像会被拒绝url
string必填可公开访问的图像 URL 或 base64 数据 URL, 例如
data:image/png;base64,...detail
string图像处理精细度
默认值:
auto可选值:
auto、low、high
reasoning_content
string历史助手消息中的推理文本;继续推理对话时应保留返回的内容, 尤其是涉及工具调用的多轮对话
tool_calls
array历史助手消息中的工具调用列表;应在对话历史中保留返回的工具调用对象
id
string必填工具调用标识符
type
string必填值:
functionfunction
object必填被调用的函数
name
string必填函数名称
arguments
string必填编码为 JSON 字符串的函数参数
tool_call_id
string
tool消息必填;与对应工具调用的标识符一致, 工具执行结果放在content中
max_tokens integer
最大输出 token 预算, 包含推理 token;应为推理过程和最终回答预留足够预算
范围:1-64K
temperature number
采样温度;值越大, 输出越随机. 通常仅调整 temperature 或 top_p 之一
范围:0.0-2.0
top_p number
核采样概率阈值
范围:(0.0, 1.0]
thinking object
控制深度思考;推理内容通过 reasoning_content 返回, 最终回答通过 content 返回
type
string必填思考开关
默认值:
enabled可选值:
enabled、disabled
reasoning_effort string
推理强度;no_think 表示关闭推理
默认值:high
可选值:high、no_think
stream boolean
以服务器发送事件(SSE)增量返回;流式对象类型为 chat.completion.chunk, 通过 choices[].delta 返回增量内容, 并以 data: [DONE] 结束
默认值:false
可选值:true、false
stream_options object
流式输出配置, 与 stream: true 配合使用
include_usage
boolean请求在
[DONE]前返回最终用量分片;该分片的choices数组可能为空
tools array
模型可调用的函数工具列表;应用执行返回的工具调用后, 将结果作为 tool 消息传入下一次请求
type
string必填值:
function
function
object必填函数定义
name
string必填函数名称
description
string函数功能及适用场景说明
parameters
objectJSON Schema 格式的函数输入参数定义
tool_choice string | object
工具选择策略;auto 由模型决定是否调用工具, none 禁用工具调用, required 强制调用工具
指定函数时使用 {"type":"function","function":{"name":"FUNCTION_NAME"}}
使用 required 或指定函数时, 通过 thinking.type: disabled 关闭思考
默认值:auto
可选值:auto、none、required、指定函数的对象
response_format object
输出格式约束;使用 json_object 时, 需在 messages 中明确要求模型输出 JSON
type
string必填输出格式
默认值:
text可选值:
text、json_object、json_schema
json_schema
object
type为json_schema时必填name
string必填Schema 名称
schema
object必填描述预期输出结构的 JSON Schema
stop string | array
遇到匹配序列时停止生成;最多接受 4 个停止序列
响应格式
id string
本次生成的唯一标识符
object string
对象类型
值:chat.completion
created integer
响应创建时间的 Unix 时间戳(秒)
model string
生成使用的模型
choices array
生成结果列表
index
integer结果索引
message
object生成的助手消息
role
string值:
assistantcontent
string | null最终回答文本;返回工具调用时可能为
nullreasoning_content
string开启思考时返回的推理文本
tool_calls
array待执行的工具调用;每项包含
id、type: function, 以及含name和 JSON 编码arguments的function对象
finish_reason
string生成结束原因, 例如
stop、length、tool_calls或content_filter
usage object
token 用量统计
prompt_tokens
integer输入 token 数
completion_tokens
integer输出 token 数, 包含推理 token
total_tokens
integer输入与输出 token 总数
prompt_tokens_details
object可选的输入 token 明细
cached_tokens
integer命中缓存的输入 token 数
completion_tokens_details
object可选的输出 token 明细
reasoning_tokens
integer推理消耗的 token 数