Kimi K3 Token Hub

Kimi K3 API: a practical quickstart

Last updated:

The Kimi K3 API is OpenAI-compatible: point any OpenAI SDK at Moonshot's base URL with a platform key and request the K3 model. Pricing is $3/M input, $15/M output, context is 1M tokens, and image input is supported. Setup takes about ten minutes; the part people skip — and regret — is the three production settings at the end.

1. Create a key

  1. Sign up at the Moonshot/Kimi developer platform (platform.kimi.ai).
  2. Add a payment method — K3 has no meaningful free API tier at launch.
  3. Create an API key in the console. Store it in an environment variable, never in client code.

2. First request (Python)

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["MOONSHOT_API_KEY"],
    base_url="https://api.moonshot.ai/v1",   # per platform docs
)

resp = client.chat.completions.create(
    model="kimi-k3",
    messages=[
        {"role": "system", "content": "You are a precise coding assistant."},
        {"role": "user", "content": "Explain this stack trace: ..."},
    ],
)
print(resp.choices[0].message.content)
print(resp.usage)  # prompt_tokens / completion_tokens — your bill

3. First request (Node)

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.MOONSHOT_API_KEY,
  baseURL: "https://api.moonshot.ai/v1",
});

const resp = await client.chat.completions.create({
  model: "kimi-k3",
  messages: [{ role: "user", content: "Summarize this log: ..." }],
});
console.log(resp.choices[0].message.content, resp.usage);

Exact base URL and model identifier can differ by region/account tier — confirm against the official quickstart before shipping.

4. The three settings that matter

  • Context caching. If you resend a large stable prefix (system prompt, repo dump), enable Moonshot's prompt caching so repeat input bills at the discounted cached rate. This is the difference between cents and dollars per agent step — model it in the cost calculator.
  • usage accounting. Log prompt_tokens and completion_tokens from every response. Reconciling them weekly against your invoice catches runaway prompts early; the token calculator helps you audit individual prompts.
  • Reasoning effort. K3 launched with a single "max" reasoning level. Watch the changelog — if lighter levels ship, they will be the cheapest quality/cost dial available.

5. Streaming, images, limits

Streaming works via the standard stream: true flag. Image input follows the OpenAI content-parts format (base64 or URL). Rate limits are account-tier dependent and published in the platform console; new accounts should expect conservative defaults and request raises with usage history. For architectural context on what K3 does well — repo navigation, tool use, log/screenshot reading — see the model overview, and for the full rate table see pricing.

Frequently asked questions

Is the Kimi K3 API OpenAI-compatible?

Yes. Moonshot exposes OpenAI-compatible chat-completions endpoints, so the official OpenAI SDKs work by changing the base URL and API key — the pattern shown in the code samples above.

How do I get a Kimi K3 API key?

Create an account on the Moonshot/Kimi developer platform (platform.kimi.ai), add billing, and generate a key from the console. Keys are scoped per project; keep them server-side.

Can I use Kimi K3 through OpenRouter instead?

Yes — OpenRouter lists moonshotai/kimi-k3 at the same $3/$15 pass-through pricing, which is convenient if you already route multiple models through one account.

Sources