Appearance
Moonshot 和 Kimi Coding 在 OpenClaw 中是两个独立提供商,Key、端点和模型 ID 前缀均不同,需分别配置。Kimi K2 系列包含 5 个模型(K2.6、K2.5、K2 Thinking、K2 Thinking Turbo、K2 Turbo),全部支持 262,144 token 上下文窗口,通过 openclaw onboard 可快速配置,openclaw models list --provider moonshot 验证模型列表。Kimi 网页搜索通过 plugins.entries.moonshot.config.webSearch 配置,支持国际和中国端点。
OpenClaw 接入 Moonshot (Kimi K2) 与 Kimi Coding 配置指南
Moonshot 通过 OpenAI 兼容端点提供 Kimi API。配置提供商后,可将默认模型设为 moonshot/kimi-k2.6,或用 Kimi Coding 端点使用 kimi/kimi-for-coding。
注意:Moonshot 和 Kimi Coding 是完全独立的提供商。API Key 不能互换,端点不同,模型引用前缀也不同(
moonshot/...vskimi/...)。
内置模型目录
| 模型引用 | 名称 | 推理能力 | 输入类型 | 上下文 | 最大输出 |
|---|---|---|---|---|---|
moonshot/kimi-k2.6 | Kimi K2.6 | 否 | text, image | 262,144 | 262,144 |
moonshot/kimi-k2.5 | Kimi K2.5 | 否 | text, image | 262,144 | 262,144 |
moonshot/kimi-k2-thinking | Kimi K2 Thinking | 是 | text | 262,144 | 262,144 |
moonshot/kimi-k2-thinking-turbo | Kimi K2 Thinking Turbo | 是 | text | 262,144 | 262,144 |
moonshot/kimi-k2-turbo | Kimi K2 Turbo | 否 | text | 256,000 | 16,384 |
当前 Moonshot 托管的 K2 模型默认使用 Moonshot 公布的按量付费单价:Kimi K2.6 缓存命中 $0.16/MTok、输入 $0.95/MTok、输出 $4.00/MTok;Kimi K2.5 缓存命中 $0.10/MTok、输入 $0.60/MTok、输出 $3.00/MTok。其他历史目录条目默认保留零成本占位符,除非在配置中覆盖。
快速开始
选择你的提供商,按以下步骤配置。
接入 Moonshot API
适用场景:通过 Moonshot Open Platform 使用 Kimi K2 系列模型。
选择端点区域
认证选项 端点 区域 moonshot-api-keyhttps://api.moonshot.ai/v1国际 moonshot-api-key-cnhttps://api.moonshot.cn/v1中国 运行 onboarding
bashopenclaw onboard --auth-choice moonshot-api-key如果需要中国端点:
bashopenclaw onboard --auth-choice moonshot-api-key-cn设置默认模型
json5{ agents: { defaults: { model: { primary: "moonshot/kimi-k2.6" }, }, }, }验证模型是否可用
bashopenclaw models list --provider moonshot运行冒烟测试
使用隔离的状态目录,不干扰正常会话:
bashOPENCLAW_CONFIG_PATH=/tmp/openclaw-kimi/openclaw.json \ OPENCLAW_STATE_DIR=/tmp/openclaw-kimi \ openclaw agent --local \ --session-id live-kimi-cost \ --message 'Reply exactly: KIMI_LIVE_OK' \ --thinking off \ --jsonJSON 响应应显示
provider: "moonshot"和model: "kimi-k2.6"。当 Moonshot 返回用量元数据时,助手的 transcript 条目会在usage.cost中记录归一化的 token 用量与估算费用。
配置示例
json5
{
env: { MOONSHOT_API_KEY: "sk-..." },
agents: {
defaults: {
model: { primary: "moonshot/kimi-k2.6" },
models: {
"moonshot/kimi-k2.6": { alias: "Kimi K2.6" },
"moonshot/kimi-k2.5": { alias: "Kimi K2.5" },
"moonshot/kimi-k2-thinking": { alias: "Kimi K2 Thinking" },
"moonshot/kimi-k2-thinking-turbo": { alias: "Kimi K2 Thinking Turbo" },
"moonshot/kimi-k2-turbo": { alias: "Kimi K2 Turbo" },
},
},
},
models: {
mode: "merge",
providers: {
moonshot: {
baseUrl: "https://api.moonshot.ai/v1",
apiKey: "${MOONSHOT_API_KEY}",
api: "openai-completions",
models: [
{
id: "kimi-k2.6",
name: "Kimi K2.6",
reasoning: false,
input: ["text", "image"],
cost: { input: 0.95, output: 4, cacheRead: 0.16, cacheWrite: 0 },
contextWindow: 262144,
maxTokens: 262144,
},
{
id: "kimi-k2.5",
name: "Kimi K2.5",
reasoning: false,
input: ["text", "image"],
cost: { input: 0.6, output: 3, cacheRead: 0.1, cacheWrite: 0 },
contextWindow: 262144,
maxTokens: 262144,
},
{
id: "kimi-k2-thinking",
name: "Kimi K2 Thinking",
reasoning: true,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 262144,
maxTokens: 262144,
},
{
id: "kimi-k2-thinking-turbo",
name: "Kimi K2 Thinking Turbo",
reasoning: true,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 262144,
maxTokens: 262144,
},
{
id: "kimi-k2-turbo",
name: "Kimi K2 Turbo",
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 256000,
maxTokens: 16384,
},
],
},
},
},
}接入 Kimi Coding
适用场景:通过 Kimi Coding 端点进行代码相关任务。
Kimi Coding 使用与 Moonshot 不同的 API Key 和提供商前缀(
kimi/...)。稳定的 API 模型引用为kimi/kimi-for-coding;旧版引用kimi/kimi-code和kimi/k2p5仍被接受,并会归一化为该 API 模型 ID。
运行 onboarding
bashopenclaw onboard --auth-choice kimi-code-api-key设置默认模型
json5{ agents: { defaults: { model: { primary: "kimi/kimi-for-coding" }, }, }, }验证模型是否可用
bashopenclaw models list --provider kimi
配置示例
json5
{
env: { KIMI_API_KEY: "sk-..." },
agents: {
defaults: {
model: { primary: "kimi/kimi-for-coding" },
models: {
"kimi/kimi-for-coding": { alias: "Kimi" },
},
},
},
}Kimi 网页搜索
OpenClaw 内置 Kimi 作为 web_search 提供商,底层使用 Moonshot 网页搜索。
运行交互式网页搜索配置
bashopenclaw configure --section web在网页搜索部分选择 Kimi,这会在
plugins.entries.moonshot.config.webSearch.*中保存配置。配置网页搜索区域与模型
交互式配置会提示:
设置 选项 API 区域 https://api.moonshot.ai/v1(国际)或https://api.moonshot.cn/v1(中国)网页搜索模型 默认为 kimi-k2.6
配置位于 plugins.entries.moonshot.config.webSearch 下:
json5
{
plugins: {
entries: {
moonshot: {
config: {
webSearch: {
apiKey: "sk-...", // 或使用 KIMI_API_KEY / MOONSHOT_API_KEY
baseUrl: "https://api.moonshot.ai/v1",
model: "kimi-k2.6",
},
},
},
},
},
tools: {
web: {
search: {
provider: "kimi",
},
},
},
}高级配置
原生思考模式
Moonshot Kimi 支持二值原生 thinking:
thinking: { type: "enabled" }thinking: { type: "disabled" }
通过 agents.defaults.models.<provider/model>.params 按模型配置:
json5
{
agents: {
defaults: {
models: {
"moonshot/kimi-k2.6": {
params: {
thinking: { type: "disabled" },
},
},
},
},
},
}OpenClaw 还映射了运行时 /think 等级:
/think 等级 | Moonshot 行为 |
|---|---|
/think off | thinking.type=disabled |
| 任意非 off 等级 | thinking.type=enabled |
当启用 Moonshot thinking 时,tool_choice 必须为 auto 或 none。OpenClaw 会自动将不兼容的 tool_choice 值规范化为 auto。
Kimi K2.6 还接受可选字段 thinking.keep,用于控制多轮对话中 reasoning_content 的保留。设置为 "all" 可在多轮中保持完整推理内容;省略或设为 null 则使用服务端默认策略。OpenClaw 只为 moonshot/kimi-k2.6 转发 thinking.keep,对其他模型会剥离此字段。
json5
{
agents: {
defaults: {
models: {
"moonshot/kimi-k2.6": {
params: {
thinking: { type: "enabled", keep: "all" },
},
},
},
},
},
}工具调用 ID 清理
Moonshot Kimi 返回形如 functions.<name>:<index> 的 tool_call ID。OpenClaw 原样保留,保证多轮工具调用正常。
如需对自定义 OpenAI 兼容提供商强制严格清理,设置 sanitizeToolCallIds: true:
json5
{
models: {
providers: {
"my-kimi-proxy": {
api: "openai-completions",
sanitizeToolCallIds: true,
},
},
},
}流式用量兼容性
原生 Moonshot 端点(https://api.moonshot.ai/v1 和 https://api.moonshot.cn/v1)在共享的 openai-completions 传输层上声明流式用量兼容性。OpenClaw 根据端点能力识别此特性,因此指向这些原生主机的自定义提供商 ID 也会继承流式用量行为。
使用绑定的 K2.6 定价时,流式返回的输入、输出和缓存读取 token 会被换算成本地估算的美元费用,出现在 /status、/usage full、/usage cost 及基于 transcript 的会话统计中。
端点与模型引用参考
| 提供商 | 模型引用前缀 | 端点 | 认证环境变量 |
|---|---|---|---|
| Moonshot | moonshot/ | https://api.moonshot.ai/v1 | MOONSHOT_API_KEY |
| Moonshot 中国 | moonshot/ | https://api.moonshot.cn/v1 | MOONSHOT_API_KEY |
| Kimi Coding | kimi/ | Kimi Coding 端点 | KIMI_API_KEY |
| 网页搜索 | 不适用 | 与 Moonshot API 区域相同 | KIMI_API_KEY 或 MOONSHOT_API_KEY |
- Kimi 网页搜索使用
KIMI_API_KEY或MOONSHOT_API_KEY,默认端点为https://api.moonshot.ai/v1,模型为kimi-k2.6。 - 如需覆盖定价和上下文元数据,可在
models.providers中调整。 - 若 Moonshot 为模型发布了不同的上下文限制,相应调整
contextWindow。
相关资源
- 模型选择 — 选择提供商、模型引用和故障转移行为。
- 网页搜索 — 配置网页搜索提供商(包括 Kimi)。
- 配置参考 — 提供商、模型和插件的完整配置 schema。
- Moonshot Open Platform — Moonshot API Key 管理及官方文档。
常见问题
Moonshot 和 Kimi Coding 的 API Key 能通用吗?
不能。两者是完全独立的提供商,Key、端点和模型 ID 前缀都不同。Moonshot 用 MOONSHOT_API_KEY,端点 api.moonshot.ai 或 api.moonshot.cn;Kimi Coding 用 KIMI_API_KEY,走自己独立的端点。混用会导致认证失败。
启用 Kimi K2 Thinking 模式时对工具调用有什么限制?
启用 thinking 后,tool_choice 必须设为 auto 或 none。OpenClaw 会自动把不兼容的值(如 required)强制改成 auto,以确保兼容。
Kimi 网页搜索的 API Key 用哪个?默认模型是什么?
Kimi 网页搜索使用 KIMI_API_KEY 或 MOONSHOT_API_KEY,默认端点为 https://api.moonshot.ai/v1,默认模型为 kimi-k2.6。可以在 plugins.entries.moonshot.config.webSearch.model 中覆盖。