Skip to main content
POST
创建一次模型响应

授权

Authorization
string
header
必填

Authorization 请求头需要一个 Bearer 令牌。使用 MOONSHOT_API_KEY 作为令牌。这是一个服务端密钥,请在 API 密钥页面 生成。

请求体

application/json
model
string
必填

使用的模型 ID。本接口当前支持 kimi-k3

示例:

"kimi-k3"

input
必填

本次请求的输入。传字符串等价于一条 user 消息;传数组时按顺序给出带类型的 item,可包含历史对话、工具调用与工具结果。

instructions
string

顶层系统指令,作为最靠前的指令生效。

stream
boolean
默认值:false

为 true 时以 SSE 事件流返回响应。

max_output_tokens
integer

本次响应最多生成的 Token 数量。kimi-k3 默认为 131072,最大可设置为 1048576。此值为期望返回的 Token 长度,而非输入加输出的总长度。达到上限时 statusincompleteincomplete_details.reasonmax_output_tokens

reasoning
object

推理相关配置。

text
object

输出文本配置。

tools
(函数工具 · object | 命名空间工具 · object)[]

模型可调用的工具列表。

工具定义,按 type 区分。

tool_choice
enum<string>

控制工具调用行为。取 auto 时由模型自行决定是否调用工具。

可用选项:
auto
prompt_cache_key
string

上下文缓存标识,同一会话使用相同取值可提升缓存命中率。

safety_identifier
string

用于检测可能违反使用政策的用户的稳定标识符。应为唯一标识每个用户的字符串。建议对用户名或邮箱进行哈希处理以避免发送可识别信息

响应

响应创建成功

一次模型响应。

id
string

响应的唯一标识符。

示例:

"resp_68f0c1c2d3e4f5a6b7c8d9e0"

object
enum<string>
可用选项:
response
created_at
integer

响应创建时的 Unix 时间戳。

completed_at
integer | null

响应结束时的 Unix 时间戳。statuscompletedincomplete 时给出,为 in_progressfailed 时是 null

status
enum<string>

响应状态。流式的起手快照为 in_progress

可用选项:
in_progress,
completed,
incomplete,
failed
model
string

产生本次响应的模型。

output
(推理 · object | 消息 · object | 函数调用 · object)[]

输出 item 数组,顺序为 reasoning、message、工具调用。

output 数组的元素,按 type 区分。

usage
object | null

本次响应的 Token 用量。

incomplete_details
object | null

statusincomplete 时给出原因。

error
object | null

statusfailed 时给出错误信息。

instructions
string | null
reasoning
object | null
text
object | null
tools
(函数工具 · object | 命名空间工具 · object)[] | null

工具定义,按 type 区分。

tool_choice
enum<string> | null

控制工具调用行为。取 auto 时由模型自行决定是否调用工具。

可用选项:
auto
max_output_tokens
integer | null
temperature
number | null
top_p
number | null
metadata
object | null
parallel_tool_calls
boolean
service_tier
string | null
store
boolean

固定为 false

background
boolean | null

固定为 false

previous_response_id
string | null

固定为 null

conversation
object | null

固定为 null