curl --request POST \
--url https://direct.evolink.ai/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "kimi-k3.1-pro",
"max_tokens": 2048,
"messages": [
{
"role": "user",
"content": "用一句话解释什么是上下文缓存。"
}
]
}
'{
"id": "chatcmpl-6adc72c2b5847b4b2ccb39fd",
"type": "message",
"role": "assistant",
"model": "kimi-k3.1-pro",
"content": [
{
"type": "text",
"thinking": "<string>",
"signature": "<string>",
"text": "上下文缓存会保存请求中重复出现的前缀内容,后续请求命中时可以更快、更省地处理。"
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 24,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 96
}
}{
"type": "error",
"error": {
"type": "<string>",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "<string>",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "<string>",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "<string>",
"message": "<string>"
},
"request_id": "<string>"
}Messages 接口
Kimi 全模型接口 - Messages 快速开始
- 使用 Anthropic Messages 协议调用 Kimi 系列模型,通过
model参数选择具体型号 - 最少只需
model、max_tokens与messages三个参数(max_tokens在 Anthropic 协议中必填) - 三个模型的上下文窗口均为 1,048,576 tokens
- 三个模型始终开启思考,思考强度放在
output_config.effort - 需要工具调用、联网搜索、图片输入、结构化输出或缓存设置,请查看完整参数页
POST
/
v1
/
messages
curl --request POST \
--url https://direct.evolink.ai/v1/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "kimi-k3.1-pro",
"max_tokens": 2048,
"messages": [
{
"role": "user",
"content": "用一句话解释什么是上下文缓存。"
}
]
}
'{
"id": "chatcmpl-6adc72c2b5847b4b2ccb39fd",
"type": "message",
"role": "assistant",
"model": "kimi-k3.1-pro",
"content": [
{
"type": "text",
"thinking": "<string>",
"signature": "<string>",
"text": "上下文缓存会保存请求中重复出现的前缀内容,后续请求命中时可以更快、更省地处理。"
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 24,
"cache_read_input_tokens": 0,
"cache_creation_input_tokens": 0,
"output_tokens": 96
}
}{
"type": "error",
"error": {
"type": "<string>",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "<string>",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "<string>",
"message": "<string>"
},
"request_id": "<string>"
}{
"type": "error",
"error": {
"type": "<string>",
"message": "<string>"
},
"request_id": "<string>"
}BaseURL 说明:默认 BaseURL 为
https://direct.evolink.ai,对文本模型支持更好,支持长连接;https://api.evolink.ai 是多模态主力地址,对文本模型作为备用地址使用。Kimi 系列始终开启思考,响应
content 里通常会带 type="thinking" 块,这部分计入 output token。因此 max_tokens 不宜设得过小,否则思考阶段可能耗尽输出预算,导致响应中没有正文。授权
##所有接口均需要使用 Bearer Token 进行认证##
获取 API Key:
访问 API Key 管理页面 获取您的 API Key
使用时在请求头中添加:
Authorization: Bearer YOUR_API_KEY
请求体
application/json
要调用的模型:
| 模型 ID | 定位 |
|---|---|
kimi-k3.1-pro | 最新一代模型(推荐) |
kimi-k3.1-pro-highspeed | 与 Pro 参数相同,生成速度更快 |
kimi-k3 | 上一代模型 |
三个模型的上下文窗口均为 1,048,576 tokens,均始终开启思考。
可用选项:
kimi-k3.1-pro, kimi-k3.1-pro-highspeed, kimi-k3 本次生成允许使用的最大 Token 数,包含 thinking 与最终文本。取值过小时,思考阶段可能耗尽输出预算,导致没有正文;建议不低于 1024,并按任务复杂度调高。
必填范围:
1 <= x <= 1048576对话消息。多轮对话时按顺序放入历史消息;回传思考与工具调用历史的方法见完整参数页。
Minimum array length:
1Show child attributes
Show child attributes
系统提示词。Messages 协议使用顶层 system,不使用 system role。
输出配置。
Show child attributes
Show child attributes
是否使用 Anthropic SSE 事件流返回。
响应
Message 响应;流式请求返回 Anthropic SSE 事件流
响应 ID。
示例:
"chatcmpl-6adc72c2b5847b4b2ccb39fd"
可用选项:
message 示例:
"message"
可用选项:
assistant 示例:
"assistant"
本次调用的模型。
示例:
"kimi-k3.1-pro"
输出内容块,通常先是 thinking,再是 text。
Show child attributes
Show child attributes
停止原因:end_turn 为自然结束,max_tokens 为达到输出上限,tool_use 为模型请求调用工具。
可用选项:
end_turn, max_tokens, tool_use, null 示例:
"end_turn"
Show child attributes
Show child attributes