Overview
Kimi K2.7-Code is a Moonshot AI model fine-tuned specifically for coding, scoring at the top of mainstream code benchmarks including HumanEval, MBPP and BigCodeBench. It supports 70+ programming languages and the major IDE protocols, handling completion, unit tests, bug fixes and cross-file refactoring in one flow — a capable assistant for day-to-day engineering and automated code workflows.
Code completion
Speaks the major IDE completion protocols with millisecond latency and cross-file context awareness.
Code generation
Generates complete functions and classes from a natural-language description, including comments, unit tests and edge-case handling.
70+ programming languages
Native support for 70+ languages including Python, JavaScript, Go, Rust and Java.
Tool calling
Function calling and the MCP protocol connect it to code search, CI/CD and internal tooling.
Features
Pricing
Rate Limits & Context
Built-in Tools
code_interpreter
Responses API
web_extractor
Responses API
web_search
Responses API
API Reference
https://api.tokenfab.com/v1/chat/completionsRequest Example
curl https://api.tokenfab.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKENFAB_API_KEY" \
-d '{
"model": "kimi-k2.7-code",
"messages": [
{"role": "system", "content": "You are a coding assistant."},
{"role": "user", "content": "Rewrite the Python function above in Go, and add unit tests and error handling."}
]
}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("TOKENFAB_API_KEY"),
base_url="https://api.tokenfab.com/v1"
)
response = client.chat.completions.create(
model="kimi-k2.7-code",
messages=[
{"role": "system", "content": "You are a coding assistant."},
{"role": "user", "content": "Rewrite the Python function above in Go, and add unit tests and error handling."}
]
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.TOKENFAB_API_KEY,
baseURL: "https://api.tokenfab.com/v1"
});
const response = await client.chat.completions.create({
model: "kimi-k2.7-code",
messages: [
{ role: "system", content: "You are a coding assistant." },
{ role: "user", content: "Rewrite the Python function above in Go, and add unit tests and error handling." }
]
});
console.log(response.choices[0].message.content);Response Example
{
"id": "chatcmpl-kimi-code-9d2k7f1",
"object": "chat.completion",
"created": 1784950000,
"model": "kimi-k2.7-code",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Here is the Go implementation, with unit tests and error handling:\n\nfunc QuickSort(arr []int) ([]int, error) {\n if len(arr) == 0 { return nil, errors.New(\"empty input\") }\n // ... (full code)\n}"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 312,
"completion_tokens": 248,
"total_tokens": 560
}
}Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | ✓ | Model ID, e.g. kimi-k2.7-code |
messages | array | ✓ | List of chat messages, each with role and content |
temperature | float | — | Sampling temperature, 0–2, default 0.7 |
top_p | float | — | Nucleus sampling, 0–1, default 0.9 |
max_tokens | int | — | Maximum output tokens |
stream | bool | — | Whether to stream the response, default false |
tools | array | — | Tool definitions for function calling |
tool_choice | string | — | Tool choice policy: auto / none / a named function |