⌘K

Hy4

hy4

Hy4 是腾讯面向推理、智能体工作流和长程生产力任务的语言模型. 支持文本和图像输入, 上下文窗口为 1024K token, 最大输入为 960K token, 最大输出为 64K token.

认证

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

文本字符串或由文本和图像内容块组成的数组;包含工具调用的助手消息可以使用 null

type string 必填

内容块类型

可选值:text、image_url

text 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 必填

值:function

function 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 object

JSON 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

值:assistant

content string | null

最终回答文本;返回工具调用时可能为 null

reasoning_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 数