Skip to content
Dashboard

Kimi K2 Thinking

Kimi K2 Thinking adds extended chain-of-thought (CoT) reasoning to the K2 architecture, supporting many sequential tool calls for agentic workflows through AI Gateway.

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

Copy link to headingPlayground

Try out Kimi K2 Thinking 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 Thinking

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
Free Tier
Release Date
216K216K0.9 s15 tps
$0.47/M
$2/M
Read$0.14/M
11/06/2025

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 Thinking 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-thinking',
prompt: 'Why is the sky blue?',
});
console.log(result.text);
}
main().catch(console.error);

Top-level parameters

The same Kimi K2 Thinking 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-thinking',
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-thinking. AI Gateway routes the request to an available provider.
maxOutputTokensnumberNoHard cap on generated tokens. Kimi K2 Thinking supports up to 216,144 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 216K-token context window

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-thinking',
prompt: 'Why is the sky blue?',
providerOptions: {
gateway: {
only: ['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-thinking',
prompt: 'Explain the Monty Hall problem step by step.',
reasoning: 'high',
});
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-thinking',
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.6 s122 tps
$4.50/M
$22.50/M
Read$0.45/M
+2
fireworks logo
morph logo
07/27/2026
1M0.6 s163 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
262K2.1 s181 tps
$1.90/M
$8/M
Read$0.38/M
+2
moonshotai logo
06/15/2026
262K0.8 s90 tps
$0.74/M+1 more
$3.50/M+1 more
Read$0.15/M
+2
baseten logo
deepinfra logo
fireworks logo
+1
06/12/2026
262K0.4 s131 tps
$0.95/M
$4/M
Read$0.16/M
+1
baseten logo
fireworks logo
moonshotai logo
+1
04/20/2026
262K0.7 s52 tps
$0.60/M
$3/M
Read$0.10/M
+1
bedrock logo
moonshotai logo
novita logo
01/26/2026

Copy link to headingAbout Kimi K2 Thinking

Standard language models produce answers directly. Input goes in, output comes out, and whatever reasoning occurred stays invisible. Kimi K2 Thinking changes the output structure. Before generating its final answer, the model produces an explicit chain-of-thought (CoT) trace: a written record of how it decomposes the problem, what options it considers, and how it reaches its conclusion.

This isn't a prompting trick. The thinking behavior is trained into the model. When K2 Thinking encounters a hard problem, its reasoning trace can run for hundreds or thousands of tokens as the model works through sub-problems, backtracks from dead ends, and synthesizes intermediate results. The final answer follows the trace.

Two practical consequences follow. First, step-by-step decomposition helps on problems that benefit from it: multi-step mathematical proofs, algorithmic design, and debugging sessions where the root cause isn't obvious. Second, the reasoning trace is also an output you can log, audit, or use in evaluations.

K2 Thinking supports long chains of sequential tool calls within a single agentic session. The model reasons about what tool to call next, observes the result, reasons about the implications, and continues. It maintains coherent task state across more interaction steps than many non-thinking models handle.

The model is open source under Moonshot AI's license terms.

Kimi K2 Thinking is available through AI Gateway at $0.47 per million input tokens and $2 per million output tokens.

Copy link to headingWhat To Consider When Choosing a Provider

  • Configuration: Reasoning traces increase output length, so budget planning should account for higher output token use relative to non-thinking K2 variants. Completions support up to 216.1K tokens per request.
  • 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 Thinking

Best for

  • Visible model reasoning: Problems where seeing the model's work matters — debugging complex logic, validating mathematical derivations, auditing decisions
  • Algorithmic exploration: Multi-step design where the model must explore and eliminate approaches before settling on a solution
  • Long tool-call chains: Agentic sessions requiring sequential tool calls with coherence across the full chain
  • Evaluation and red-teaming: Workflows where reasoning traces surface failure modes and edge cases

Consider alternatives when

  • Straightforward tasks: Standard Kimi K2 is faster and cheaper for direct-answer tasks that don't benefit from deliberation
  • Hard latency constraints: Reasoning traces add significant generation time
  • Output cost sensitivity: Thinking traces can multiply output length by 3 to 10x
  • Speed-optimized reasoning: Kimi K2 Thinking Turbo trades some reasoning depth for lower latency

Kimi K2 Thinking restructures model output around explicit reasoning. For problems that reward deliberation, the visible chain-of-thought adds an auditable record of the model's logic. Long chains of sequential tool calls extend this into agentic workflows. Reserve it for tasks where the thinking trace earns its token cost. Use non-thinking variants for everything else.

Copy link to headingFrequently Asked Questions

  • How does the reasoning trace change what I get back from the API?

    You get two parts: a thinking section with the chain-of-thought trace, and a final answer section with the conclusion. The trace shows problem decomposition, intermediate steps, considered alternatives, and the logical path to the answer. Both sections count toward output token usage.

  • What kinds of problems benefit most from the thinking mode?

    Multi-step proofs, debugging where the root cause isn't immediately apparent, algorithmic optimization with competing approaches, and problems where the model needs to try and discard wrong paths. Simple factual questions and routine code generation often don't justify the added cost and latency.

  • How long are the reasoning traces in practice?

    Length varies with problem difficulty. A moderately complex coding problem might produce 500 to 1,000 tokens of reasoning. A hard mathematical proof or multi-step debugging session can generate 3,000 to 5,000+ tokens. The model scales its deliberation to the perceived difficulty of the task.

  • Can I use reasoning traces for model evaluation and quality assurance?

    Yes. Traces show where the model reasons correctly, where it makes assumptions, and where it backtracks. You can check whether the model reached a correct answer through step-by-step reasoning or pattern matching, which helps on domain-specific tasks.

  • What makes long tool-call chains important for reasoning workflows?

    Each tool call is a reasoning decision: the model decides what to call, interprets the result, and picks the next step. Long chains let the model keep coherent task reasoning across more steps than many models support, so you can run automation pipelines that would otherwise need multiple sessions.

  • Does K2 Thinking always produce a reasoning trace, or can I turn it off?

    It always produces a reasoning trace. For direct answers without traces, use standard Kimi K2 or Kimi K2-0905. They share the same K2 architecture without the deliberative reasoning layer.

Your use is subject to Moonshot AI's Terms & Privacy Policies.