The short version, in 6 steps
- Create an account on the Kimi API platform. Sign up at platform.kimi.ai. This is the developer platform, which is separate from the consumer Kimi app and billed separately.
- Top up your balance. The platform is pay-as-you-go, so add credit before you call the API. Kimi K3 unlocks only after a top-up of at least $1.
- Generate an API key. Create a key in the user centre and store it in an environment variable. Never commit it to source control.
- Install an OpenAI-compatible SDK. Install the official OpenAI SDK for your language. The Kimi API implements the same Chat Completions interface.
- Point the client at Moonshot. Set base_url to https://api.moonshot.ai/v1 and pass your Kimi API key as api_key.
- Make your first request. Call chat.completions.create with a model identifier such as kimi-k3 and a messages array.
What do you need before you start?
You will need an account on the Kimi API platform with some credit (more on that below) and an API key. You will also need an SDK that's compatible with OpenAI API. There's no special Kimi SDK for you to get familiar with.
Kimi API platform is not the same as Kimi app nor Kimi Code. Those are separate products with separate billings as well. Neither your Kimi Membership subscription can be used to call Kimi API nor vice versa.
Kimi K3 can only be called with accounts that have topped up at least $1. You won't be able to if you just signed up.
How do you get a Kimi API key?
Sign up at the Kimi API platform and grab an API key from your user centre.
I recommend to always:
- store the API key in an environment variable instead of hard-coding it.
- keep
.envon.gitignorefrom the beginning. Leaked API keys can be picked up by scanners within minutes. - use different API keys for different environments (development, staging, production, etc.) so that you can revoke one without affecting the others.
export MOONSHOT_API_KEY="sk-..."
How do you make your first request?
Install OpenAI SDK and set base URL to Moonshot's. If you are already using OpenAI in your code, all you need to do is to change those two options (and the model name, of course).
For example, in Python:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["MOONSHOT_API_KEY"],
base_url="https://api.moonshot.ai/v1",
)
response = client.chat.completions.create(
model="kimi-k2.6",
messages=[
{"role": "system", "content": "You are a concise technical assistant."},
{"role": "user", "content": "Explain a context window in two sentences."},
],
)
print(response.choices[0].message.content)
And in JavaScript:
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.MOONSHOT_API_KEY,
baseURL: 'https://api.moonshot.ai/v1',
});
const response = await client.chat.completions.create({
model: 'kimi-k2.6',
messages: [
{ role: 'system', content: 'You are a concise technical assistant.' },
{ role: 'user', content: 'Explain a context window in two sentences.' },
],
});
console.log(response.choices[0].message.content);
Which model should you use?
Kimi offers different models for different use cases, with different pricing. Try them all with a small input to find what works best for you. There's no commitment since you select the model per each API call.
Note that as of writing, Moonshot doesn't maintain and support kimi-k2.5 (since 31 August 2026) and the entire kimi-k2-* series (since 25 May 2026). Some older articles/tutorials might still reference those models.
See all Kimi models side by side to compare the models, or check the cost for your use case with our calculator.
| Model identifier | Use it for | Output per 1M |
|---|---|---|
kimi-k2.6 |
General-purpose default | $4.00 |
kimi-k2.7-code |
Coding tasks | $4.00 |
kimi-k2.7-code-highspeed |
Coding, latency-critical | $8.00 |
kimi-k3 |
Long context, hardest reasoning | $15.00 |
How does reasoning effort work on Kimi K3?
Unlike with some other models, you can't disable reasoning altogether when using Kimi K3. There's always some reasoning involved with every request. The depth of reasoning can be controlled with reasoning_effort top-level option that can take low, high or max values.
It defaults to max!
Keep that in mind, since reasoning tokens are billed as output tokens ($15.00 per million). Sticking with the default might get expensive for simple requests sent in large volumes. I recommend to always explicitly state what level of reasoning effort you need.
Another thing to note, by default, Kimi K3 won't produce more than 131,072 tokens (you can set the limit as high as 1,048,576 tokens with max_completion_tokens option, that's the entire context window).
response = client.chat.completions.create(
model="kimi-k3",
messages=messages,
reasoning_effort="low", # default is "max"
)
Which request settings can you actually change?
All the currently available Kimi models have fixed sampling options. That is, you might need to remove lines specifying temperature or top_p from your code before it'll work with Kimi. Here's what Kimi currently supports, as per Moonshot's documentation:
| Setting | Kimi K3 | Kimi K2.7 Code | Kimi K2.6 |
|---|---|---|---|
temperature |
Fixed at 1.0. Leave it out | Fixed at 1.0. Other values error | 1.0, or 0.6 with thinking off. Other values error |
top_p |
Fixed at 0.95. Leave it out | Fixed at 0.95. Other values error | Fixed at 0.95. Other values error |
| Output cap when unset | 131,072 tokens | 32,768 tokens | 32,768 tokens |
| Turn reasoning off | No. Lower it with reasoning_effort |
No. Disabling thinking errors | Yes, with thinking disabled |
tool_choice |
Can require a tool call | auto or none only |
auto or none while thinking |
Likewise, n and both penalties are not adjustable. My general recommendation is to only specify the options you really need.
How do you turn thinking off?
Out of all currently available Kimi models, only Kimi K2.6 can have reasoning (aka thinking) disabled. Thinking is on by default, but it can be turned off on a per-request basis by adding a thinking object to the request body. Note that the option is not (yet?) supported by OpenAI SDK, so it has to be passed via extra_body:
response = client.chat.completions.create(
model="kimi-k2.6",
messages=messages,
extra_body={"thinking": {"type": "disabled"}},
)
It's worth turning thinking off for relatively straightforward tasks, such as data extraction or classification, where reasoning won't bring you anything, but will eat into your Kimi budget.
Kimi K2.7 Code will return an error if you try to disable thinking, and Kimi K3 always performs thinking (though it might be worth setting reasoning_effort="low" to keep it from overthinking).
How do you send an image or a video?
Kimi expects a list of objects (aka "parts") to be provided as message content if you want to provide it with images and/or videos. Images can be passed as base64 data URLs (Kimi K3 won't accept public image URLs), videos as pre-uploaded files, referenced by their id.
import base64
from pathlib import Path
image = base64.b64encode(Path("chart.png").read_bytes()).decode()
response = client.chat.completions.create(
model="kimi-k3",
messages=[{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": f"data:image/png;base64,{image}"}},
{"type": "text", "text": "What does this chart show?"},
],
}],
)
In case of videos, the first step would be uploading the video:
video = client.files.create(file=Path("demo.mp4"), purpose="video")
response = client.chat.completions.create(
model="kimi-k3",
messages=[{
"role": "user",
"content": [
{"type": "video_url", "video_url": {"url": f"ms://{video.id}"}},
{"type": "text", "text": "Summarise this video."},
],
}],
)
client.files.delete(video.id)
Next, you can refer to the video in your messages. Video input is currently supported by Kimi K3, Kimi K2.7 Code (regular and HighSpeed) and Kimi K2.6, according to Moonshot's documentation.
Make sure that content is an actual list and not serialized into a string. In the latter case Moonshot makes no guarantees about interpreting it as an image/video input.
What does streaming look like?
Streaming works in a standard OpenAI-compatible way. You pass stream=True and process chunks in a loop:
stream = client.chat.completions.create(
model="kimi-k2.6",
messages=messages,
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)
Streaming is useful in any situation where you display LLM's responses to end users as they're being generated. Overall generation time hardly matters in such situations. It's the time-to-first-token that primarily defines the perceived responsiveness of your application. And streaming is free!
You might've noticed that there's an extra reasoning_content field in the response chunks above. Thinking-capable models can stream their reasoning alongside the final response. The example above ignores the field and only prints the final response.
What changes in multi-turn conversations and tool calls?
The best practice when dealing with thinking-capable models is to include full assistant responses (not only the content field!) in subsequent requests. Kimi K3 documentation explicitly asks you to do so, Kimi K2.7 Code and K2.6 docs recommend including reasoning_content in the history, especially for multi-step tool calls.
Omitting reasoning_content won't result in an error, at least for Kimi K2.7 Code and K2.6, but might negatively affect the performance of subsequent tool calls, according to Moonshot.
Yes, it does mean more input tokens, but that's precisely the scenario when context caching can come in handy!
response = client.chat.completions.create(model="kimi-k3", messages=messages)
# Append the message object itself, reasoning included, then add the next turn.
messages.append(response.choices[0].message)
messages.append({"role": "user", "content": "Now shorten that to one sentence."})
How do you count tokens before you send a request?
Moonshot provides a handy heuristic. English text amounts to roughly 3 to 4 characters per token, which might be helpful when planning your prompts and responses. Code and other languages might have different (likely higher!) number of tokens per character, so account for that.
Alternatively, you can use Moonshot's token calculation API to get the exact number of tokens that will be used by a real-life request, or my token counter for a quick estimate right in your browser!
When making actual LLM calls, you can use usage.prompt_tokens and usage.completion_tokens to figure out the exact number of input/output tokens used (and, hence, billed!).
What should you know about rate limits and cost before going to production?
Moonshot measures rate limits in four different ways. Concurrent connections, requests per minute (RPM), tokens per minute (TPM) and tokens per day (TPD). You'll be rate-limited once any of these is exceeded!
Moonshot provides an illustrative example of making 20 requests with prompts/responses of ~100 tokens each. This might exhaust your requests per minute limit (say, if it's 20 RPM), even though you're far from exceeding any token-based limits.
Consider implementing exponential backoff for 429 responses from day one! Rate limits increase as your tier increases, tiers, in turn, are determined by the total amount of money you topped up with so far.
As I already mentioned, Moonshot automatically caches the common prefix between repeated prompts. Input tokens served from the context cache might cost as little as a tenth of non-cached input tokens (depending on the model), which can drastically change the economics of your Moonshot API-powered app.
This is where the structure of your prompts might matter. Make sure to put the common, repetitive, identical between calls part (system prompt? tool definitions? few-shot examples?) first, and, of course, don't change it (even slightly!). Depending on the setup, this can matter even more than model selection!
It's not the time to discuss Kimi API pricing in detail. Check out this detailed article if you want to learn more, including the specifics of context cache tiers (such as Kimi K3's unusually long, 1-hour context cache TTL).
Frequently asked questions
Is the Kimi API compatible with OpenAI?
The Kimi API offers an OpenAI-compatible Chat Completions API, which means you can use it with the official OpenAI SDKs without major changes to your code.
What is the Kimi API base URL?
The base URL for the global Kimi API is https://api.moonshot.ai/v1. Simply pass it as the base_url along with your API key from the Kimi platform when initializing an OpenAI-compatible client.
Is the Kimi API free?
Kimi API uses a pay-as-you-go pricing model based on the number of tokens processed, with no subscription options. You need to top up the balance before making any API calls. Note that the Kimi K3 model will only be available if you have topped up at least $1. Please note that Kimi API billing is independent from both Kimi Membership and Kimi Code.
Which Kimi model should I start with?
kimi-k2.6 or kimi-k2.7-code are a good choice to start with, depending on whether you want a general or a code-specialised model, respectively. They're also quite cheap at $4.00 per million output tokens! kimi-k3 is a good choice if you need a 1,048,576-token context window and/or top-notch reasoning capabilities, and don't mind paying $15.00 per million output tokens for that.
Can I set temperature on Kimi models?
At the moment, temperature parameter is not configurable for any of the Moonshot models. As of writing, Kimi K3, Kimi K2.7 Code and Kimi K2.6 models run with temperature fixed to 1.0, 1.0 and 0.6 (when thinking is disabled), respectively, and top_p fixed to 0.95. While specifying different values on K2.6 and K2.7 Code will result in an error, on K3 you're simply advised not to pass these parameters at all.
Do I need a different API key for each Kimi model?
Nope! A single API key can be used with all the models hosted on the Kimi API platform. You simply use the model parameter to specify which model to use, so it's trivial to switch between Kimi models.
What are the Kimi API rate limits?
There are four types of rate limits on the Kimi API platform. Concurrent connections, requests per minute, tokens per minute and tokens per day. Your actual rate limits will depend on your account's tier. You can find more details on the rate limits page of the platform.
Models mentioned
Kimi K3 is Moonshot AI’s flagship model, with 2.8 trillion parameters, native visual understanding and a 1,048,576-token context window.
Kimi K2.7 Code is Moonshot AI’s coding-focused model, with a 262,144-token context window and higher instruction-following reliability in long contexts.
Kimi K2.6 is a general-purpose model with a 262,144-token context window, supporting text, image and video input across thinking and non-thinking modes.