Kimi K2.7-Code 把推理 token 砍掉 30%,在长程编码任务上有实打实的提升,是编码智能体赛道的一个有力信号,做代码 Agent 的可以盯一下。
Kimi K2.7-Code 是一个开源编码模型,相比同类模型拥有更高的模型 token 效率,能够用更少的 token 完成相同的代码生成任务。模型已在 HuggingFace 上发布。
Kimi K2.7 Code 是一个以编程为焦点的智能体模型,基于 Kimi K2.6 构建。在真实世界的长周期编程任务上有了显著改进,它增强了跨复杂软件工程工作流的端到端任务完成能力,同时提升了模型 token 效率,与 Kimi K2.6 相比,思考模型 token 使用量减少了约 30%。
| 架构 | 混合专家(MoE) |
| 总参数量 | 1T |
| 激活参数量 | 32B |
| 层数(含稠密层) | 61 |
| 稠密层数量 | 1 |
| 注意力隐藏层维度 | 7168 |
| MoE 隐藏层维度(每专家) | 2048 |
| 注意力头数 | 64 |
| 专家数量 | 384 |
| 每个 token 选择的专家数 | 8 |
| 共享专家数量 | 1 |
| 词表大小 | 160K |
| 上下文长度 | 256K |
| 注意力机制 | MLA |
| 激活函数 | SwiGLU |
| 视觉编码器 | MoonViT |
| 视觉编码器参数量 | 400M |
| 基准测试 | Kimi K2.6 | Kimi K2.7 Code | GPT-5.5 | Claude Opus 4.8 |
|---|---|---|---|---|
| 编程 | ||||
| Kimi Code Bench v2 | 50.9 | 62.0 | 69.0 | 67.4 |
| Program Bench | 48.3 | 53.6 | 69.1 | 63.8 |
| MLS Bench Lite | 26.7 | 35.1 | 35.5 | 42.8 |
| 智能体 | ||||
| Kimi Claw 24/7 Bench | 42.9 | 46.9 | 52.8 | 50.4 |
| MCP Atlas | 69.4 | 76.0 | 79.4 | 81.3 |
| MCP Mark Verified | 72.8 | 81.1 | 92.9 | 76.4 |
Kimi-K2.7-Code 采用与 Kimi-K2-Thinking 相同的原生 int4 量化方法。
您可以在 https://platform.moonshot.ai 上访问 Kimi-K2.7-Code 的 API,我们为您提供与 OpenAI/Anthropic 兼容的 API。目前,建议在以下推理引擎上运行 Kimi-K2.7-Code:
Kimi-K2.7-Code 与 Kimi-K2.5/Kimi-K2.6 架构相同,可直接复用部署方法。
transformers 版本要求为 >=4.57.1, <5.0.0。
部署示例请参见模型部署指南。
以下使用示例演示如何调用我们的官方 API。请注意,Kimi-K2.7-Code 强制要求 thinking 和 preserve_thinking 为 True。
对于使用 vLLM 或 SGLang 部署的第三方 API,请注意:
与视频内容聊天是一项实验性功能,目前仅在我们官方 API 中支持。
Thinking 模式下的推荐温度为 1.0。
推荐 top_p 为 0.95。
不支持即时模式。
这是一个简单的聊天补全脚本,演示如何在 Thinking 模式下调用 K2.7-Code API。
import openai
import base64
import requests
def simple_chat(client: openai.OpenAI, model_name: str):
messages = [
{'role': 'system', 'content': 'You are Kimi, an AI assistant created by Moonshot AI.'},
{
'role': 'user',
'content': [
{'type': 'text', 'text': 'which one is bigger, 9.11 or 9.9? think carefully.'}
],
},
]
response = client.chat.completions.create(
model=model_name, messages=messages, stream=False, max_tokens=4096
)
print('====== Below is reasoning content in Thinking Mode ======')
print(f'reasoning content: {response.choices[0].message.reasoning}')
print('====== Below is response in Thinking Mode ======')
print(f'response: {response.choices[0].message.content}')
K2.7-Code 支持图像和视频输入。
以下示例演示如何使用图像输入调用 K2.7-Code API:
import openai
import base64
import requests
def chat_with_image(client: openai.OpenAI, model_name: str):
url = 'https://huggingface.co/moonshotai/Kimi-K2.7-Code/resolve/main/figures/kimi-logo.png'
image_base64 = base64.b64encode(requests.get(url).content).decode()
messages = [
{
'role': 'user',
'content': [
{'type': 'text', 'text': 'Describe this image in detail.'},
{
'type': 'image_url',
'image_url': {'url': f'data:image/png;base64,{image_base64}'},
},
],
}
]
response = client.chat.completions.create(
model=model_name, messages=messages, stream=False, max_tokens=8192
)
print('====== Below is reasoning content in Thinking Mode ======')
print(f'reasoning content: {response.choices[0].message.reasoning}')
print('====== Below is response in Thinking Mode ======')
print(f'response: {response.choices[0].message.content}')
以下示例演示如何使用视频输入调用 K2.7-Code API:
import openai
import base64
import requests
def chat_with_video(client: openai.OpenAI, model_name:str):
url = 'https://huggingface.co/moonshotai/Kimi-K2.7-Code/resolve/main/figures/demo_video.mp4'
video_base64 = base64.b64encode(requests.get(url).content).decode()
messages = [
{
"role": "user",
"content": [
{"type": "text","text": "Describe the video in detail."},
{
"type": "video_url",
"video_url": {"url": f"data:video/mp4;base64,{video_base64}"},
},
],
}
]
response = client.chat.completions.create(model=model_name, messages=messages)
print('====== Below is reasoning content in Thinking Mode ======')
print(f'reasoning content: {response.choices[0].message.reasoning}')
print('====== Below is response in Thinking Mode ======')
print(f'response: {response.choices[0].message.content}')
Kimi K2.7 Code 强制启用 preserve_thinking 模式,该模式在多轮交互中保留完整推理内容,并提升编码智能体场景下的性能。
此功能默认启用且无法禁用。以下示例演示如何在 preserve_thinking 模式下调用 K2.7-Code API:
def chat_with_preserve_thinking(client: openai.OpenAI, model_name: str):
messages = [
{
"role": "user",
"content": "Tell me three random numbers."
},
{
"role": "assistant",
"reasoning_content": "I'll start by listing five numbers: 473, 921, 235, 215, 222, and I'll tell you the first three.",
"content": "473, 921, 235"
},
{
"role": "user",
"content": "What are the other two numbers you have in mind?"
}
]
response = client.chat.completions.create(
model=model_name,
messages=messages,
stream=False,
max_tokens=4096,
)
print(f"response: {response.choices[0].message.reasoning}")
return response.choices[0].message.content
K2.7-Code 与 K2 Thinking 采用相同的交错思考与多步工具调用设计。使用示例请参考 K2 Thinking 文档。
Kimi K2.7-Code 与 Kimi Code CLI(作为其智能体框架)配合使用效果最佳——请前往 https://www.kimi.com/code 尝试。
代码仓库和模型权重均依据修改版 MIT 许可证发布。
请参见 THIRD PARTY NOTICES
如有任何疑问,请通过 support@moonshot.ai 联系我们。
Kimi K2.7-Code 把推理 token 砍掉 30%,在长程编码任务上有实打实的提升,是编码智能体赛道的一个有力信号,做代码 Agent 的可以盯一下。
Kimi K2.7-Code 是一个开源编码模型,相比同类模型拥有更高的模型 token 效率,能够用更少的 token 完成相同的代码生成任务。模型已在 HuggingFace 上发布。
Kimi K2.7 Code 是一个以编程为焦点的智能体模型,基于 Kimi K2.6 构建。在真实世界的长周期编程任务上有了显著改进,它增强了跨复杂软件工程工作流的端到端任务完成能力,同时提升了模型 token 效率,与 Kimi K2.6 相比,思考模型 token 使用量减少了约 30%。
| 架构 | 混合专家(MoE) |
| 总参数量 | 1T |
| 激活参数量 | 32B |
| 层数(含稠密层) | 61 |
| 稠密层数量 | 1 |
| 注意力隐藏层维度 | 7168 |
| MoE 隐藏层维度(每专家) | 2048 |
| 注意力头数 | 64 |
| 专家数量 | 384 |
| 每个 token 选择的专家数 | 8 |
| 共享专家数量 | 1 |
| 词表大小 | 160K |
| 上下文长度 | 256K |
| 注意力机制 | MLA |
| 激活函数 | SwiGLU |
| 视觉编码器 | MoonViT |
| 视觉编码器参数量 | 400M |
| 基准测试 | Kimi K2.6 | Kimi K2.7 Code | GPT-5.5 | Claude Opus 4.8 |
|---|---|---|---|---|
| 编程 | ||||
| Kimi Code Bench v2 | 50.9 | 62.0 | 69.0 | 67.4 |
| Program Bench | 48.3 | 53.6 | 69.1 | 63.8 |
| MLS Bench Lite | 26.7 | 35.1 | 35.5 | 42.8 |
| 智能体 | ||||
| Kimi Claw 24/7 Bench | 42.9 | 46.9 | 52.8 | 50.4 |
| MCP Atlas | 69.4 | 76.0 | 79.4 | 81.3 |
| MCP Mark Verified | 72.8 | 81.1 | 92.9 | 76.4 |
Kimi-K2.7-Code 采用与 Kimi-K2-Thinking 相同的原生 int4 量化方法。
您可以在 https://platform.moonshot.ai 上访问 Kimi-K2.7-Code 的 API,我们为您提供与 OpenAI/Anthropic 兼容的 API。目前,建议在以下推理引擎上运行 Kimi-K2.7-Code:
Kimi-K2.7-Code 与 Kimi-K2.5/Kimi-K2.6 架构相同,可直接复用部署方法。
transformers 版本要求为 >=4.57.1, <5.0.0。
部署示例请参见模型部署指南。
以下使用示例演示如何调用我们的官方 API。请注意,Kimi-K2.7-Code 强制要求 thinking 和 preserve_thinking 为 True。
对于使用 vLLM 或 SGLang 部署的第三方 API,请注意:
与视频内容聊天是一项实验性功能,目前仅在我们官方 API 中支持。
Thinking 模式下的推荐温度为 1.0。
推荐 top_p 为 0.95。
不支持即时模式。
这是一个简单的聊天补全脚本,演示如何在 Thinking 模式下调用 K2.7-Code API。
import openai
import base64
import requests
def simple_chat(client: openai.OpenAI, model_name: str):
messages = [
{'role': 'system', 'content': 'You are Kimi, an AI assistant created by Moonshot AI.'},
{
'role': 'user',
'content': [
{'type': 'text', 'text': 'which one is bigger, 9.11 or 9.9? think carefully.'}
],
},
]
response = client.chat.completions.create(
model=model_name, messages=messages, stream=False, max_tokens=4096
)
print('====== Below is reasoning content in Thinking Mode ======')
print(f'reasoning content: {response.choices[0].message.reasoning}')
print('====== Below is response in Thinking Mode ======')
print(f'response: {response.choices[0].message.content}')
K2.7-Code 支持图像和视频输入。
以下示例演示如何使用图像输入调用 K2.7-Code API:
import openai
import base64
import requests
def chat_with_image(client: openai.OpenAI, model_name: str):
url = 'https://huggingface.co/moonshotai/Kimi-K2.7-Code/resolve/main/figures/kimi-logo.png'
image_base64 = base64.b64encode(requests.get(url).content).decode()
messages = [
{
'role': 'user',
'content': [
{'type': 'text', 'text': 'Describe this image in detail.'},
{
'type': 'image_url',
'image_url': {'url': f'data:image/png;base64,{image_base64}'},
},
],
}
]
response = client.chat.completions.create(
model=model_name, messages=messages, stream=False, max_tokens=8192
)
print('====== Below is reasoning content in Thinking Mode ======')
print(f'reasoning content: {response.choices[0].message.reasoning}')
print('====== Below is response in Thinking Mode ======')
print(f'response: {response.choices[0].message.content}')
以下示例演示如何使用视频输入调用 K2.7-Code API:
import openai
import base64
import requests
def chat_with_video(client: openai.OpenAI, model_name:str):
url = 'https://huggingface.co/moonshotai/Kimi-K2.7-Code/resolve/main/figures/demo_video.mp4'
video_base64 = base64.b64encode(requests.get(url).content).decode()
messages = [
{
"role": "user",
"content": [
{"type": "text","text": "Describe the video in detail."},
{
"type": "video_url",
"video_url": {"url": f"data:video/mp4;base64,{video_base64}"},
},
],
}
]
response = client.chat.completions.create(model=model_name, messages=messages)
print('====== Below is reasoning content in Thinking Mode ======')
print(f'reasoning content: {response.choices[0].message.reasoning}')
print('====== Below is response in Thinking Mode ======')
print(f'response: {response.choices[0].message.content}')
Kimi K2.7 Code 强制启用 preserve_thinking 模式,该模式在多轮交互中保留完整推理内容,并提升编码智能体场景下的性能。
此功能默认启用且无法禁用。以下示例演示如何在 preserve_thinking 模式下调用 K2.7-Code API:
def chat_with_preserve_thinking(client: openai.OpenAI, model_name: str):
messages = [
{
"role": "user",
"content": "Tell me three random numbers."
},
{
"role": "assistant",
"reasoning_content": "I'll start by listing five numbers: 473, 921, 235, 215, 222, and I'll tell you the first three.",
"content": "473, 921, 235"
},
{
"role": "user",
"content": "What are the other two numbers you have in mind?"
}
]
response = client.chat.completions.create(
model=model_name,
messages=messages,
stream=False,
max_tokens=4096,
)
print(f"response: {response.choices[0].message.reasoning}")
return response.choices[0].message.content
K2.7-Code 与 K2 Thinking 采用相同的交错思考与多步工具调用设计。使用示例请参考 K2 Thinking 文档。
Kimi K2.7-Code 与 Kimi Code CLI(作为其智能体框架)配合使用效果最佳——请前往 https://www.kimi.com/code 尝试。
代码仓库和模型权重均依据修改版 MIT 许可证发布。
请参见 THIRD PARTY NOTICES
如有任何疑问,请通过 support@moonshot.ai 联系我们。