DeepSeek-V4.1-Flash1M context, web search, and tool calling fully supported
Try it now

Kimi K2.7-Code

kimi-k2.7-code
Open sourceKimi series

Overview

262K ContextCode generationReasoningMCP

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

Tool calling✓
Structured output✓
Context caching✓
Batch✓
Web search✓
Streaming✓
Reasoning✓
MCP✓
Prefix completion✕
Fine-tuning✕

Pricing

Input$0.95/M tokens
Input (cache hit)$0.19/M tokens
Output$4/M tokens

Rate Limits & Context

Context Window262K
Max Output262K
RPM (requests/min)500
TPM (tokens/min)1M

Built-in Tools

code_interpreter

Responses API

web_extractor

Responses API

web_search

Responses API

API Reference

POSThttps://api.tokenfab.com/v1/chat/completions

Request 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."}
    ]
  }'

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

ParameterTypeRequiredDescription
modelstring✓Model ID, e.g. kimi-k2.7-code
messagesarray✓List of chat messages, each with role and content
temperaturefloat—Sampling temperature, 0–2, default 0.7
top_pfloat—Nucleus sampling, 0–1, default 0.9
max_tokensint—Maximum output tokens
streambool—Whether to stream the response, default false
toolsarray—Tool definitions for function calling
tool_choicestring—Tool choice policy: auto / none / a named function