Kimi K2.7 Code API
Kimi K2.7 Code is Moonshot AI's coding-focused agentic model built on Kimi K2.6, with 1T total parameters and 32B active parameters. It always operates in thinking mode, supports text and image input, and targets long-horizon software engineering, agentic task decomposition, and multi-turn coding workflows with 256K context.
Input: USD 0.75 / 1M tokens; Output: USD 3.5 / 1M tokens
Public ID: kimi-k2-7-code
Model types: Chat
Reasoning Tool calling Vision Optimized for code Structured output
Pricing
Input · USD 0.75 / 1M tokens
Output · USD 3.5 / 1M tokens
Cache read · USD 0.16 / 1M tokens
Cache write · USD 0.75 / 1M tokens
Model specifications
- Model types
- Chat / Image
- Context window (tokens)
- 256000
- Maximum output (tokens)
- 65536
- Reasoning
- Supported
- Tool calling
- Supported
- Vision
- Supported
- Optimized for code
- Supported
- Structured output
- Supported
Privacy
Unknown
Unknown means no verified service-wide guarantee is published. Uncensored does not guarantee every request succeeds.
Quick start
Check that this model is returned for your API key, then review the documented input options for its capability.
Set GLOOP_API_BASE to your API origin and GLOOP_API_KEY to your server-side key.
curl
curl --fail-with-body "${GLOOP_API_BASE%/}/v1/chat/completions" \
-H "Authorization: Bearer $GLOOP_API_KEY" \
-H 'Content-Type: application/json' \
--data-raw '{
"messages": [
{
"content": "Hello",
"role": "user"
}
],
"model": "kimi-k2-7-code"
}'Python
import os, json, urllib.request
url = os.environ['GLOOP_API_BASE'].rstrip('/') + "/v1/chat/completions"
headers = {'Authorization': 'Bearer ' + os.environ['GLOOP_API_KEY']}
headers['Content-Type'] = 'application/json'
data = "{\n \"messages\": [\n {\n \"content\": \"Hello\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"kimi-k2-7-code\"\n}".encode('utf-8')
request = urllib.request.Request(url, data=data, headers=headers)
with urllib.request.urlopen(request) as response:
print(json.load(response))Node.js
const url = process.env.GLOOP_API_BASE.replace(/\/$/, '') + "/v1/chat/completions";
const headers = { Authorization: `Bearer ${process.env.GLOOP_API_KEY}` };
headers['Content-Type'] = 'application/json';
const response = await fetch(url, { method: 'POST', headers, body: JSON.stringify({
"messages": [
{
"content": "Hello",
"role": "user"
}
],
"model": "kimi-k2-7-code"
}) });
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());
Run this example only after checking model access and pricing. Copying does not call the API.
View API guide · Model discovery · SDK integration · Billing
FAQ
Kimi K2.7 Code — Which model ID should I use?
kimi-k2-7-code
Kimi K2.7 Code — How is this model priced?
Input: USD 0.75 / 1M tokens; Output: USD 3.5 / 1M tokens
Kimi K2.7 Code — Which API endpoints are supported?
/v1/chat/completions
Kimi K2.7 Code — What is the context window?
256000 tokens