Skip to content
Moonshot AI logo

Kimi K3

Text GenerationMoonshot AI

Kimi K3 is Moonshot's flagship 2.8 trillion-parameter model, built on Kimi Delta Attention (a hybrid linear attention mechanism) with Attention Residuals. It offers native visual understanding, always-on reasoning, and a 1M-token context window for long-horizon coding, knowledge work, and deep reasoning tasks.

Model Info
Context Window1,048,576 tokens
More informationlink
Request formatsChat Completions
PricingView pricing in the Cloudflare dashboard

Usage

TypeScript
const response = await env.AI.run(
'moonshotai/kimi-k3',
{ messages: [{ content: 'Explain quantum entanglement in simple terms.', role: 'user' }] },
)
console.log(response)
Quantum entanglement is when two particles become linked in such a way that they behave as a single system — even when separated by vast distances.

**An analogy to start:**
Imagine two coins that are mysteriously connected. You shuffle them, keep one, and mail the other to a friend across the world. The moment you look at your coin and see heads, you instantly know your friend's coin shows tails.

**Here's where it gets weird:**
With ordinary coins, the outcome was fixed all along — your coin was *already* heads before you looked. But quantum mechanics says something stranger: before measurement, entangled particles don't have definite properties at all. Each exists in a haze of possibilities (called "superposition"). The instant you measure one, it "settles" into a state — and its partner instantly takes on the matching state, no matter how far away it is.

**Why this bothered Einstein:**
He famously called it "spooky action at a distance," because it seemed like the particles were communicating faster than light — which relativity says is impossible. He suspected the particles carried hidden instructions all along. But experiments over the past few decades (recognized with the 2022 Nobel Prize in Physics) proved Einstein wrong: the correlations are real, and the particles genuinely don't have definite states until measured.

**One important caveat:**
You *can't* use entanglement to send messages faster than light. The outcome you see is random, so there's no way to encode information in it. The connection only becomes apparent when both sides compare their results through normal, slower-than-light channels.

**Why it matters:**
Entanglement isn't just a curiosity — it's the foundation of quantum computing, ultra-secure quantum cryptography, and emerging quantum communication networks.

In short: entangled particles share one fate, and measuring one instantly shapes the other — a phenomenon so strange that even Einstein refused to believe it.

Examples

Reasoning Effort — Configure reasoning effort for a harder problem (K3's reasoning_effort replaces the K2.x thinking parameter)
TypeScript
const response = await env.AI.run(
'moonshotai/kimi-k3',
{
messages: [{ content: 'Prove that the square root of 2 is irrational.', role: 'user' }],
reasoning_effort: 'max',
},
)
console.log(response)
# Proof that √2 is irrational

**Theorem.** √2 is irrational.

**Proof.** We proceed by contradiction. Suppose √2 is rational. Then it can be written as a fraction in lowest terms:

$$\sqrt{2} = \frac{a}{b}$$

where $a$ and $b$ are integers, $b \neq 0$, and $\gcd(a, b) = 1$ (meaning $a$ and $b$ share no common factor).

**Step 1: Square both sides.**

$$2 = \frac{a^2}{b^2} \implies a^2 = 2b^2$$

So $a^2$ is even. This forces $a$ itself to be even, because the square of an odd number is odd: if $a = 2k+1$, then $a^2 = 4k^2 + 4k + 1$, which is odd. Hence we can write:

$$a = 2k \quad \text{for some integer } k$$

**Step 2: Substitute back.**

$$(2k)^2 = 2b^2 \implies 4k^2 = 2b^2 \implies b^2 = 2k^2$$

So $b^2$ is even, and by the same reasoning as above, $b$ must be even.

**Step 3: Reach a contradiction.**

We have shown that both $a$ and $b$ are even, so they share a common factor of 2. But this contradicts our assumption that $\gcd(a, b) = 1$.

**Conclusion.** The assumption that √2 is rational leads to a contradiction. Therefore, √2 is irrational. $\blacksquare$

---

**Remark on the key step:** The entire proof hinges on the fact that *every* rational number has a unique fully-reduced form. The equation $a^2 = 2b^2$ is impossible for reduced fractions because the factor 2 appears an even number of times on the left (in the prime factorization of $a^2$) but an odd number of times on the right (in $2b^2$) — this is essentially the contradiction in disguise.
Tool Choice Required — Force a tool call on the first turn with tool_choice
TypeScript
const response = await env.AI.run(
'moonshotai/kimi-k3',
{
messages: [{ content: 'What is the weather in San Francisco today?', role: 'user' }],
tool_choice: 'required',
tools: [
{
function: {
description: 'Get the weather for a city',
name: 'get_weather',
parameters: {
properties: { city: { type: 'string' } },
required: ['city'],
type: 'object',
},
},
type: 'function',
},
],
},
)
console.log(response)
I'll check the weather in San Francisco for you.
Streaming Response — Enable streaming for real-time output
TypeScript
const response = await env.AI.run(
'moonshotai/kimi-k3',
{ messages: [{ content: 'Explain why the sky is blue.', role: 'user' }], stream: true },
)
console.log(response)
The sky is blue because of a phenomenon called **Rayleigh scattering**, which describes how light interacts with tiny particles—in this case, the gas molecules in Earth's atmosphere.

Here's the process, step by step:

1. **Sunlight contains all colors.** Although it looks white, sunlight is actually a mix of every color of visible light, each with a different wavelength. Red light has long wavelengths (~700 nm), while blue and violet have short ones (~400–450 nm).

2. **Air molecules scatter light.** Nitrogen and oxygen molecules are far smaller than the wavelengths of visible light. When light strikes particles this tiny, it gets scattered in all directions.

3. **Shorter wavelengths scatter much more strongly.** Rayleigh scattering intensity is proportional to 1/λ⁴, meaning blue light is scattered roughly 5–6 times more than red light. As sunlight streams through the atmosphere, blue light gets bounced all over the place—so no matter where you look in the sky, scattered blue light is reaching your eyes.

**Why not violet?** Violet light scatters even more than blue, but the sun emits less of it, and our eyes are less sensitive to it. The combined effect is that we perceive the sky as blue.

**A nice confirmation:** the same physics explains sunsets. When the sun is low on the horizon, its light travels through much more atmosphere to reach you. By the time it arrives, most of the blue has been scattered away, leaving the reds and oranges behind.

As a bonus: on the Moon, which has no atmosphere, the daytime sky is black—there's nothing to scatter the sunlight at all.

Parameters

temperature
numberminimum: 0maximum: 2
max_tokens
numberexclusiveMinimum: 0
max_completion_tokens
numberexclusiveMinimum: 0
top_p
numberminimum: 0maximum: 1
frequency_penalty
numberminimum: -2maximum: 2
presence_penalty
numberminimum: -2maximum: 2
stream
boolean
tool_choice
response_format

API Schemas (Raw)

Input
Output