Try Kimi at kimi.com →

Kimi K3 API

This guide shows developers how to call Kimi K3, Moonshot AI's most capable model, from their own software. It covers the model name, a first request you can copy, how to control how hard it thinks, tool calls, caching, prices and fixes for common errors. Everything here follows Moonshot's own documentation.

For developersCopy-and-paste code
YOUR REQUEST "model": "kimi-k3", "reasoning_effort": "low" | "high" | "max", "messages": [ ... ] How hard should it think? lowhighmax faster, cheaperdeepest, default reasoning_contentthe thinking contentthe answer

One extra setting matters most with Kimi K3: how much effort it puts into thinking.

We are an independent guide. We are not Moonshot AI. API keys are created only on Moonshot's platform, and we never ask for yours. The code on this page follows Moonshot's documentation, but we could not run it against the live API, so test it with a small request first.
CHEAT SHEET

The key facts

MODEL NAME
kimi-k3
BASE URL
https://api.moonshot.ai/v1
WORKS WITH
The OpenAI SDK. An Anthropic-style address is also offered
CONTEXT
1,048,576 tokens
OUTPUT LIMIT
131,072 tokens by default (max_completion_tokens)
THINKING
Always on. reasoning_effort: low, high or max
INPUT
Text, images and video
PRICE PER MILLION TOKENS
$3.00 in · $0.30 cached · $15.00 out

From Moonshot's Kimi K3 quickstart and price page. Prices exclude tax.

Step 1

Before you start

  1. Sign in to Moonshot's API platform at platform.kimi.ai and add a small balance. The minimum is $1.
  2. Create an API key in the console. Copy it straight away.
  3. Save it as an environment variable named MOONSHOT_API_KEY. Do not paste it into your code.
  4. For Python, install the OpenAI SDK: pip install --upgrade "openai>=1.0". For Node, run npm install openai.
Keep your key private. Anyone with the key can spend your balance. Never put it in a website's front-end code, a public repository or a chat message.

Need more detail on keys and accounts? See Kimi API setup.

Step 2

Your first request

All three examples ask Kimi K3 a simple question and print the answer. They use low effort and a small output limit to keep the test cheap.

curl
curl https://api.moonshot.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MOONSHOT_API_KEY" \
  -d '{
    "model": "kimi-k3",
    "reasoning_effort": "low",
    "max_completion_tokens": 4096,
    "messages": [
      {"role": "user", "content": "Explain what an API is in two sentences."}
    ]
  }'

Written for this guide in the standard OpenAI format, using the address, model name and settings from Moonshot's quickstart. Notice what is missing: no temperature setting. An older OpenAI SDK may not accept reasoning_effort or max_completion_tokens, so update it first.

Step 3

Choose the reasoning effort

Kimi K3 always thinks before it answers, and you cannot switch that off. What you can set is how much effort it spends. More effort usually means better answers on hard problems, with a longer wait and a bigger bill, because thinking is charged as output.

"low"

The quickest and cheapest. A sensible choice for simple questions, short edits and tests.

"high"

A middle setting for everyday coding and analysis.

"max"

The deepest thinking, and the default if you set nothing. Best kept for the hardest jobs.

The three values and the default are from Moonshot's reasoning effort guide. The advice on when to use each is ours. Moonshot's guide does not give figures for the difference, so measure it on your own tasks.

Moving from an older Kimi model? Remove the old thinking setting from your requests. Kimi K3 uses the top-level reasoning_effort field instead.
IMPORTANT

Settings you cannot change

Moonshot fixes several settings for Kimi K3 and says to leave them out of requests.

SettingFixed atWhat to do
temperature1.0Leave it out
top_p0.95Leave it out
n1Leave it out. One answer per request
presence_penalty0Leave it out
frequency_penalty0Leave it out
ThinkingAlways onUse reasoning_effort to turn it down

On a small screen, swipe the table sideways to see every column.

Many libraries send a temperature by default. If yours does, look for a way to remove it. Need thinking switched off completely? Use kimi-k2.6 for those calls.

BUILD

Streaming and thinking

Each reply has two parts: reasoning_content, the model's thinking, and content, the final answer. Show content to your users.

With streaming on, the reply arrives piece by piece. The thinking comes first, then the answer. Streaming is worth using with Kimi K3, because deep thinking can take a while and a request with no response for 900 seconds times out.

  • If you ask for JSON, read it from content only.
  • Thinking and the answer share one output limit.
python · streaming
stream = client.chat.completions.create(
    model="kimi-k3",
    reasoning_effort="high",
    stream=True,
    messages=[{"role": "user", "content": "Plan a 3-step database migration."}],
)

for chunk in stream:
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta
    thinking = getattr(delta, "reasoning_content", None)
    if thinking:
        print(thinking, end="", flush=True)   # the model's reasoning
    if delta.content:
        print(delta.content, end="", flush=True)  # the answer

Continues from the Python example above. A teaching example written for this guide.

BUILD

Tool calls

Tools let Kimi K3 do real work: search, read files, run code. Moonshot's guides set out a few rules that matter more for this model than for older ones.

Pass everything back

After each reply, add the complete assistant message to your history, unchanged, including reasoning_content and tool_calls. Kimi K3 was trained to see its earlier thinking.

Answer every call

Add one tool message for each call, with the matching tool_call_id.

Do not list every tool

For large tool sets, Moonshot suggests starting with a few core tools plus one "search tools" function, then adding others only when needed.

Force a first step if needed

Set tool_choice to "required" on the first turn to make the model call a tool, then go back to "auto".

Do not switch models mid-conversation. Moonshot's launch post warns that quality can become unstable if you change to Kimi K3 partway through a session, or if a tool drops its earlier thinking. It also says Kimi K3 can be too eager to act, so state clear limits in your system prompt.

For a full tool loop in Python, see the example on the Kimi K2.7 Code API page. The pattern is the same.

BUILD

Images and video

  • The message content must be a list of parts, not plain text.
  • Images: send base64, or a reference to an uploaded file that starts with ms://. Public image links are not supported.
  • Video: upload the file first, then refer to it in a video_url part.
  • Pictures and video use tokens too, so they add to the input cost.
json · a message with an image
{
  "role": "user",
  "content": [
    {"type": "image_url",
     "image_url": {"url": "data:image/png;base64,PASTE_BASE64_HERE"}},
    {"type": "text", "text": "What does this chart show?"}
  ]
}
SAVE

Caching: pay less for repeated text

If many requests start with the same long text, such as instructions or a codebase, Kimi K3 can remember it. Later requests then pay $0.30 per million tokens for that part instead of $3.00. It happens automatically.

  • Put the fixed text first and the part that changes last.
  • Keep the fixed text exactly the same. Leave out dates, times and random IDs.
  • The cache lasts 5 minutes by default, or 1 hour if you ask for it.
  • Saving to the cache has a one-off charge: $3.00 per million tokens for 5 minutes, $6.00 for 1 hour.
  • Check usage.prompt_tokens_details.cached_tokens in the reply to see what was reused.
json · ask for a 1-hour cache
{
  "model": "kimi-k3",
  "prompt_cache_options": {"mode": "implicit", "ttl": "1h"},
  "messages": [
    {"role": "system", "content": "LONG FIXED INSTRUCTIONS AND REFERENCE TEXT"},
    {"role": "user", "content": "The question that changes each time"}
  ]
}

From Moonshot's context caching guide. Text is cached in blocks, and a part smaller than one block is charged at the normal price. The guide does not give the block size.

COST

Prices and calculator

Per million tokensPrice
Input$3.00
Cached input$0.30
Saving to the cache, 5 minutes$3.00
Saving to the cache, 1 hour$6.00
Output, including thinking$15.00

Enter a month's usage to see the bill, next to the same work on Kimi K2.6.

Kimi K2.6, a month$0
Kimi K3, a month$0

List prices before tax. It leaves out the one-off charge for saving to the cache and any web search calls. The Kimi K2.6 figure uses $0.95 in, $0.16 cached and $4.00 out. Kimi K3 always thinks before answering, so its output may be higher than Kimi K2.6 with thinking off.

Moonshot's batch price page lists only Kimi K2.7 Code and Kimi K2.6, so Kimi K3 does not appear to be offered at the cheaper batch rate. More: API pricing · rate limits and enterprise pricing · API vs subscription

FIX

Common errors

CodeWhat it meansWhat to do
400A setting is not allowedRemove temperature, top_p, n and the penalty settings. Remove any older thinking setting and use reasoning_effort
400The request is too longShorten the input or lower the output limit. Everything must fit in 1,048,576 tokens
400Image link rejectedPublic image links are not supported. Send base64 or an uploaded file reference
401The key is wrong or missingCheck the Authorization: Bearer header. A Kimi Code membership key will not work on this address
404Model not foundCheck the spelling: kimi-k3. Also check that your account has access
429Rate limit reachedSlow down or wait. New accounts are limited to 3 requests a minute until total top-ups reach $10
429Servers are busyWait and retry with growing pauses. Topping up does not help with this one
504Timed outLong thinking can pass the time limit. Turn on streaming with "stream": true

On a small screen, swipe the table sideways to see every column.

From Moonshot's error code page and Kimi K3 guides. More help: Kimi not working?

CHECKLIST

Before you go live

0 of 7 done
Watch the output limit. The default is 131,072 tokens. At $15 per million, one runaway reply could cost about $2. Set a lower limit while you test.
Start on a low rate limit. A new account at Tier 0 allows 1 request at a time and 3 a minute. Total top-ups of $10 raise that to 15 at a time and 100 a minute.
FAQ

Kimi K3 API questions

Use kimi-k3. The base URL is https://api.moonshot.ai/v1 and the API works with the OpenAI SDK. An Anthropic-style address is also offered for tools such as Claude Code.

$3.00 per million input tokens, $0.30 for cached input and $15.00 per million output tokens, before tax. Saving text to the cache costs $3.00 per million tokens for 5 minutes or $6.00 for 1 hour.

No. Kimi K3 always reasons before it answers. You can lower the cost and wait by setting reasoning_effort to low or high instead of the default, max.

Moonshot fixes temperature, top_p, n and the penalty settings for Kimi K3. Leave them out of your request.

1,048,576 tokens, about 1 million. The default output limit is 131,072 tokens, and it can be raised.

Yes. Send images as base64 or as an uploaded file reference. Public image links are not supported. Video must be uploaded as a file first.
NEXT

Related guides

Create your key on Moonshot's platform

API keys and billing are on Moonshot AI's own site, never on this page. We are an independent guide.