K2.6 API 默认开启 thinking、固定一组采样参数,并要求工具多轮保留 reasoning_content;如果要使用官方 $web_search,当前文档建议先关闭 thinking。
适合的任务:文本/图像/视频理解、代码 Agent、函数工具调用和 256K 长上下文对话。
不适合的任务:在 thinking 模式下直接调用官方 $web_search;文档明确称该组合暂时不兼容。
适用的模型版本:kimi-k2.6。
适用的客户端、Agent 或 API:Kimi OpenAI-compatible API、Python OpenAI SDK、Kimi Code。
推荐的推理档位和参数:默认使用 thinking: {"type":"enabled"};默认 max_tokens=32768。不要手动传与固定值不同的 temperature/top-p/n/penalty。
curl https://api.moonshot.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MOONSHOT_API_KEY" \
-d '{
"model": "kimi-k2.6",
"messages": [{"role": "user", "content": "hello"}],
"thinking": {"type": "disabled"}
}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("MOONSHOT_API_KEY"),
base_url="https://api.moonshot.ai/v1",
)
response = client.chat.completions.create(
model="kimi-k2.6",
messages=[
{"role": "user", "content": "先分析约束,再完成任务并给出可验证的结果。"}
],
extra_body={"thinking": {"type": "enabled"}},
max_tokens=32768,
)
print(response.choices[0].message.content)对于工具循环,保留 assistant 消息中的 reasoning_content;tool_choice 只能是 auto 或 none。图像/视频输入按官方示例使用 base64;文档建议图片不超过 4K、视频不超过 FHD,URL 图片目前不支持。
先用无工具的 thinking 请求确认 SDK、base URL、模型名和 API key 正常。
增加函数工具,固定 tool_choice="auto",把每轮完整 assistant 消息(含 reasoning_content 和 tool calls)回填上下文。
若需要 $web_search,切换到 thinking: {"type":"disabled"},并单独记录该模式的质量/成本差异。
对图像/视频任务先估算 token,超过请求体限制或需要重复引用时使用文件上传而非 base64。
在 256K 长上下文附近测试上下文裁剪、工具回传和失败恢复,不把默认 32K 输出上限误认为上下文窗口。
文档列出模型上下文为 256K;输入支持 text/image/video,支持 thinking 与 non-thinking、对话和 Agent 任务。
max_tokens 默认 32768;thinking 默认启用;thinking 时 temperature 固定 1.0,non-thinking 固定 0.6;top-p 固定 0.95;n 固定 1;presence/frequency penalty 固定 0.0,传入其他值会报错。
工具调用约束:tool_choice 只能 auto/none;多步调用必须保留 reasoning_content;官方 $web_search 暂不兼容 K2.6/K2.5 thinking。
视觉建议:图片不超过 4096×2160,视频不超过 1920×1080;URL 格式图片不支持,图片数量无硬限制但请求体不得超过 100M。
文档中“视觉模型”能力依赖输入格式和客户端;第三方 provider 可能不暴露图像输入,不能把 Kimi API 的能力直接外推到所有聚合平台。
固定采样参数意味着不能通过 temperature/top-p 做常规随机性调节;需要比较时必须记录 thinking 开关和 provider。
把 reasoning_content 回传给 API 是状态连续性要求,不等于应把内部推理全文展示给用户。
文档的代码示例包含视觉与工具用法,但未提供每种输入的完整成本样本;上线前应自行测 token 和延迟。
官方提示在 thinking 工具调用中 “must keep the reasoning_content”,并说明 $web_search “temporarily incompatible”;这两条是 K2.6 接入最容易踩的配置边界。
Kimi K2.6