Skip to content
Dashboard

Kimi K2.7 Code

Kimi K2.7 Code is Moonshot AI's coding-focused agentic model with stronger coding and agent performance than Kimi K2.6, less overthinking, and a context window of 262.1K tokens, available through AI Gateway via Moonshot AI, DeepInfra, Fireworks, Baseten. Your use is subject to Moonshot AI's Terms & Privacy Policies.

View API reference
Input and output price
Prices from: Input $0.74, Output $3.50, Per 1M tokens
24h uptime
Loading AI Gateway uptime
import { streamText } from 'ai'
const result = streamText({
model: 'moonshotai/kimi-k2.7-code',
prompt: 'Why is the sky blue?'
})
Read docs

Copy link to headingPlayground

Try out Kimi K2.7 Code by Moonshot AI. Usage is billed to your team at API rates. Free users (those who haven't made a payment) get $5 of credits every 30 days.

moonshotai logo
moonshotai logo

Kimi K2.7 Code

Copy link to headingProviders

Route requests across multiple providers. Copy a provider slug to set your preference. Visit the docs for more info. Using a provider means you agree to their terms, listed under Legal.

Provider
Context
Max Output
Latency
Throughput
Input
Output
Cache
Web Search
Capabilities
ZDR
No Training
Regional Inference
Free Tier
Release Date
256K33K1.0 s47 tps
$0.95/M+1 more
$4/M+1 more
Read$0.19/M
+2
06/12/2026
262K33K0.5 s20 tps
$0.74/M
$3.50/M
Read$0.15/M
+1
06/12/2026
Going away Sep 25, 2026Legal:TermsPrivacy
262K33K0.2 s144 tps
$0.95/M
$4/M
Read$0.19/M
+2
06/12/2026
256K33K0.6 s252 tps
$0.95/M
$4/M
Read$0.16/M
+2
US
06/12/2026

Copy link to headingUptime

Direct request success rate on AI Gateway and per-provider. Visit the docs for more info.

Copy link to headingThroughput

P50 throughput on live AI Gateway traffic, in tokens per second (TPS). Visit the docs for more info.

Copy link to headingLatency

P50 time to first token (TTFT) on live AI Gateway traffic, in milliseconds. View the docs for more info.

Getting started

Call Kimi K2.7 Code through AI Gateway with the AI SDK generateText and streamText functions, or through the OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages APIs by changing the base URL. AI Gateway authenticates the request and routes it to an available provider.

Install the AI SDK (pnpm add ai dotenv), create an API key from the API Keys page, and set it as AI_GATEWAY_API_KEY in your environment. Full setup is covered in the text generation quickstart.

index.ts
import { generateText } from 'ai';
import 'dotenv/config';
async function main() {
const result = await generateText({
model: 'moonshotai/kimi-k2.7-code',
prompt: 'Why is the sky blue?',
});
console.log(result.text);
}
main().catch(console.error);

Top-level parameters

The same Kimi K2.7 Code request in each API format AI Gateway supports.

top-level-params.ts
import { generateText } from 'ai';
import 'dotenv/config';
async function main() {
const result = await generateText({
model: 'moonshotai/kimi-k2.7-code',
system: 'You are a concise technical assistant.',
prompt: 'Summarize the tradeoffs between static generation and SSR.',
maxOutputTokens: 1024,
});
console.log(result.text);
}
main().catch(console.error);

Standard parameters like prompt, messages, temperature, and tools work as documented in the AI SDK docs. These are the parameters with model-specific behavior.

ParameterTypeRequiredDescription
modelstringYesModel ID in the form creator/model, e.g. moonshotai/kimi-k2.7-code. AI Gateway routes the request to an available provider.
maxOutputTokensnumberNoHard cap on generated tokens. Kimi K2.7 Code supports up to 32,768 output tokens. Reasoning tokens count toward this limit.
reasoning'provider-default' | 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh'NoProvider-agnostic reasoning effort, available in AI SDK 7 or later. Maps to the provider’s native reasoning configuration; reasoning settings under providerOptions take precedence when both are set. See the Reasoning section below.
providerOptionsRecord<string, JSONValue>NoAI Gateway routing options under gateway, plus any provider-native options under the provider’s own namespace — see the table below.

Input limits

InputFormatsSourcesMax countMax sizeLimits
TextPrompt and response share the 262K-token context window
ImageURL, base64, Uint8ArraySent as image parts in messages; counts as input tokens
PDFURL, base64, Uint8ArraySent as file parts in messages; counts as input tokens

Provider options

Set AI Gateway routing options under providerOptions.gateway. For provider-specific options, pass them under the provider’s namespace as documented by the AI SDK.

Learn more in the AI SDK moonshotai provider docs.

provider-options.ts
import { generateText } from 'ai';
import 'dotenv/config';
async function main() {
const result = await generateText({
model: 'moonshotai/kimi-k2.7-code',
prompt: 'Why is the sky blue?',
providerOptions: {
gateway: {
only: ['moonshotai', 'deepinfra'],
},
},
});
console.log(result.text);
}
main().catch(console.error);

These AI Gateway routing options apply to every model. Provider-specific options pass through under the provider’s own namespace (for example providerOptions.anthropic) exactly as documented by the AI SDK.

ParameterTypeRequiredDescription
providerOptions.gateway.onlystring[]NoRestrict routing to these provider slugs. Requests fail over only within the listed providers.
providerOptions.gateway.orderstring[]NoPreferred provider order. Listed providers are tried first; unlisted providers remain available as fallbacks.
providerOptions.gateway.sort'cost' | 'ttft' | 'tps'NoRank candidate providers by price, time to first token, or tokens per second instead of the default routing order.
providerOptions.gateway.zeroDataRetentionbooleanNoRoute only to providers with a zero-data-retention policy for this model.

Routing across providers

AI Gateway serves the same model through multiple providers and fails over automatically. order expresses a preference while keeping every provider eligible; only is a hard allowlist — if none of the listed providers are available the request fails instead of falling back.

Options under a provider's own namespace (for example providerOptions.anthropic) are forwarded to that provider with the request. Providers ignore option namespaces that don't apply to them, so it is safe to set provider options alongside gateway routing options.

Reasoning

AI Gateway bridges reasoning across every API format. The AI SDK exposes a provider-agnostic top-level reasoning level (none, minimal, low, medium, high, or xhigh); the Chat Completions and Responses formats take the same effort under reasoning.effort; and the Anthropic Messages format uses a native thinking token budget. Whichever you send, the gateway maps it to the target model’s native configuration, converting between effort levels and token budgets as needed. Reasoning-related settings under providerOptions take full precedence over the top-level reasoning value and are never merged. Reasoning tokens typically count toward your output-token usage, though how they’re reported and billed varies by provider.

Learn more in the AI Gateway reasoning guide.

reasoning.ts
import { generateText } from 'ai';
import 'dotenv/config';
async function main() {
const result = await generateText({
model: 'moonshotai/kimi-k2.7-code',
prompt: 'Explain the Monty Hall problem step by step.',
reasoning: 'high',
});
console.log(result.text);
}
main().catch(console.error);

Image input

Send images alongside text as message parts. Images count as input tokens.

image-input.ts
import { generateText } from 'ai';
import 'dotenv/config';
async function main() {
const result = await generateText({
model: 'moonshotai/kimi-k2.7-code',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Describe this image.' },
{ type: 'image', image: 'https://example.com/photo.jpg' },
],
},
],
});
console.log(result.text);
}
main().catch(console.error);

PDF input

Attach PDFs as file parts. Their contents count as input tokens.

pdf-input.ts
import { generateText } from 'ai';
import 'dotenv/config';
async function main() {
const result = await generateText({
model: 'moonshotai/kimi-k2.7-code',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Summarize this document.' },
{
type: 'file',
mediaType: 'application/pdf',
data: 'https://example.com/document.pdf',
},
],
},
],
});
console.log(result.text);
}
main().catch(console.error);

Tool calling

Expose tools the model can call. Define each tool’s inputs with a Zod schema.

tool-calling.ts
import { generateText, tool } from 'ai';
import { z } from 'zod';
import 'dotenv/config';
async function main() {
const result = await generateText({
model: 'moonshotai/kimi-k2.7-code',
prompt: 'What is the weather in San Francisco?',
tools: {
getWeather: tool({
description: 'Get the current weather for a location',
inputSchema: z.object({ location: z.string() }),
execute: async ({ location }) => ({ location, temperatureC: 18 }),
}),
},
});
console.log(result.text);
}
main().catch(console.error);

Copy link to headingMore models by Moonshot AI

Model
Context
Latency
Throughput
Input
Output
Cache
Web Search
Capabilities
Providers
ZDR
No Training
Free Tier
Release Date
1M1.1 s117 tps
$4.50/M
$22.50/M
Read$0.45/M
+2
fireworks logo
morph logo
07/27/2026
1M0.5 s263 tps
$2.50/M+1 more
$12.75/M+1 more
Read$0.29/M
+2
alibaba logo
baseten logo
blackbox logo
+11
07/16/2026
262K0.9 s349 tps
$1.90/M
$8/M
Read$0.38/M
+2
moonshotai logo
06/15/2026
262K0.3 s132 tps
$0.95/M
$4/M
Read$0.16/M
+1
baseten logo
fireworks logo
moonshotai logo
+1
04/20/2026
262K0.7 s59 tps
$0.60/M
$3/M
Read$0.10/M
+1
bedrock logo
moonshotai logo
novita logo
01/26/2026
216K0.7 s39 tps
$0.47/M
$2/M
Read$0.14/M
deepinfra logo
11/06/2025

Copy link to headingAbout Kimi K2.7 Code

Kimi K2.7 Code, released on June 12, 2026, is Moonshot AI's coding-focused successor to Kimi K2.6. Kimi K2.7 Code is a Mixture-of-Experts model with one trillion total parameters and 32 billion active per forward pass, published under a Modified MIT license. Moonshot AI tunes this release for three things: stronger coding and agent performance, more efficient reasoning, and better instruction following across long-horizon coding sessions.

The efficiency shift is concrete. Kimi K2.7 Code spends roughly 30% fewer thinking tokens than Kimi K2.6 on average, which Moonshot AI frames as less overthinking. On Moonshot AI's own benchmark suite, Kimi K2.7 Code scores 62.0 on Kimi Code Bench V2 against 50.9 for Kimi K2.6, and 81.1 on MCP Mark Verified against 72.8. Treat those as vendor-reported numbers; they come from internal benchmarks without third-party verification at release.

Long-horizon execution is the other documented gain. Moonshot AI reports improved success on sequences exceeding 4,000 tool calls and runs lasting over 12 hours of continuous execution. The improvements generalize across Rust, Go, and Python, and across task types like frontend work, DevOps, and performance optimization. Reasoning stays on for every request: Kimi K2.7 Code always thinks before answering, and that mode can't be disabled.

Input is natively multimodal. Kimi K2.7 Code accepts images in formats like PNG, JPEG, WebP, and GIF, plus video in MP4, MOV, AVI, and others, with temporal analysis for video understanding. A coding agent can read a screenshot of a broken layout or a screen recording of a bug without a separate vision model in the pipeline.

Access Kimi K2.7 Code through AI Gateway by setting the model string to moonshotai/kimi-k2.7-code. Use the AI SDK or any supported interface like Chat Completions, Responses, or Messages, and AI Gateway routes across Moonshot AI, DeepInfra, Fireworks, Baseten with automatic failover. If you want faster serving of the same weights, kimi-k2.7-code-highspeed runs this model on a higher-throughput tier.

Kimi K2.7 Code supports a context window of 262.1K tokens and completions up to 32.8K tokens per request. Pricing through AI Gateway is $0.74 per million input tokens and $3.5 per million output tokens, with cached input at $0.15 per million tokens.

Copy link to headingWhat To Consider When Choosing a Provider

  • Configuration: Kimi K2.7 Code always reasons before answering, and thinking mode can't be switched off. Budget output tokens for reasoning traces on top of the code Kimi K2.7 Code writes, and note the completion cap of 32.8K tokens per request. If deliberation never helps your workload, a non-thinking Kimi K2 variant avoids the reasoning overhead entirely.
  • Zero Data Retention: Zero Data Retention is available for this model. It is offered on a per-provider and model basis. See the documentation for details.
  • Authentication: AI Gateway authenticates requests using an API key or OIDC token. You do not need to manage provider credentials directly.

Copy link to headingWhen to Use Kimi K2.7 Code

Best for

  • Long-horizon coding agents: Sessions that chain thousands of tool calls and keep executing for hours without losing the task thread
  • Token-efficient reasoning: Coding workloads that benefit from thinking but paid too much reasoning overhead on earlier variants
  • Multi-language engineering: Refactors, DevOps automation, and performance work across Rust, Go, and Python codebases
  • Visual debugging inputs: Screenshots and screen recordings that feed directly into the coding loop without a separate vision model

Consider alternatives when

  • Faster serving of the same weights: Kimi K2.7 Code High Speed runs the identical model on a higher-throughput tier for latency-sensitive agents
  • Optional thinking mode: A non-thinking Kimi K2 variant skips the always-on reasoning when deliberation adds cost without quality
  • Work beyond code: Kimi K2.6 covers broader design-with-code and general multimodal workflows
  • Visible reasoning traces: Kimi K2 Thinking emits full chain-of-thought for products that surface deliberation to users

Kimi K2.7 Code narrows the Kimi line's focus to agentic coding and spends its reasoning budget more carefully than Kimi K2.6 did. For coding agents that run long, call many tools, and need thinking without the overthinking tax, it's the variant to reach for.

Copy link to headingFrequently Asked Questions

  • What's new in Kimi K2.7 Code compared to Kimi K2.6?

    Three things: stronger coding and agent performance, roughly 30% fewer thinking tokens on average, and better instruction following in long-horizon coding sessions. Moonshot AI's internal benchmarks show gains like 62.0 against 50.9 on Kimi Code Bench V2; treat those as vendor-reported numbers.

  • Can I turn off thinking mode on Kimi K2.7 Code?

    No. Kimi K2.7 Code always reasons before answering, and the mode can't be disabled. Budget output tokens for reasoning traces, and use a non-thinking Kimi K2 variant if deliberation never helps your workload.

  • Does Kimi K2.7 Code accept images and video?

    Yes. Kimi K2.7 Code takes images in formats like PNG, JPEG, WebP, and GIF, plus video in MP4, MOV, AVI, and others, with temporal analysis for video understanding. Confirm modality limits on https://platform.kimi.ai/docs/guide/kimi-k2-7-code-quickstart before you build a media-heavy pipeline.

  • How long can Kimi K2.7 Code run in a single agentic session?

    Moonshot AI reports improved success on sequences exceeding 4,000 tool calls and runs lasting over 12 hours of continuous execution. Plan your agent harness and token budgets around extended runs.

  • Is Kimi K2.7 Code open weights?

    Yes. Moonshot AI publishes the weights under a Modified MIT license. Through AI Gateway you get hosted access without managing the trillion-parameter deployment yourself.

  • How do I use Kimi K2.7 Code on AI Gateway?

    Use the identifier moonshotai/kimi-k2.7-code with the AI SDK or any supported interface like Chat Completions, Responses, or Messages. AI Gateway routes across moonshotai, deepinfra, fireworks, baseten and handles failover automatically.

  • Does Kimi K2.7 Code support zero data retention?

    Yes, Zero Data Retention is available for this model. Zero Data Retention is offered on a per-provider basis. See https://vercel.com/docs/ai-gateway/capabilities/zdr for details.