Kimi K2.7 Code 是在 Kimi K2.6 基础上构建的专注于编码任务的智能体模型。该模型在真实世界的长周期编码任务上进行了显著改进,增强了复杂软件工程工作流中的端到端任务完成能力,同时提升了令牌效率,与 Kimi K2.6 相比,思考令牌使用量减少约 30%。
| 架构 | 混合专家模型(Mixture-of-Experts, MoE) |
| 总参数量 | 1T |
| 激活参数量 | 32B |
| 层数(包含稠密层) | 61 |
| 稠密层层数 | 1 |
| 注意力隐藏维度 | 7168 |
| MoE 隐藏维度(每个专家) | 2048 |
| 注意力头数 | 64 |
| 专家数量 | 384 |
| 每令牌选择专家数 | 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 量化方法。
[!Note] 您可以通过 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,请注意:
[!Note]
视频内容对话是一项实验性功能,目前仅在我们的官方 API 中支持。
思考模式(Thinking mode)推荐的
temperature为1.0。推荐的
top_p为0.95。不支持即时模式(Instant mode)。
这是一个简单的对话补全脚本,展示了如何在思考模式(Thinking mode)下调用 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.",
# Some API (e.g. vLLM) may not support reasoning_content, you can try reasoning instead
"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,
)
# the assistant should mention 215 and 222 that appear in the prior reasoning content
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 进行尝试。
代码仓库和模型权重均基于 Modified MIT License 发布。
如有任何问题,请通过 support@moonshot.ai 与我们联系。