How to Use the Kimi K3 API
Get a Moonshot API key, make your first call, and integrate Kimi K3 into the tools you already use
The Kimi API lets your apps send prompts to Moonshot AI's Kimi models and get answers back. This guide shows a business team how to use the Kimi K3 API in plain steps.
You will learn how to get an API key, where the endpoint lives, and how to make your first call. We keep the code short so a non-specialist can follow along.
The best part for most teams: the Kimi API is OpenAI-compatible. If your stack already talks to ChatGPT, you can point it at Kimi with only small changes.
How to Get a Kimi API Key
You get a Kimi API key from Moonshot's developer platform at platform.moonshot.ai. It is the official console for keys, billing, and usage.
Create an account, then open the API keys page and generate a new key. Copy it once and store it safely, because the console shows the full key only at creation time.
Moonshot's hosted API is paid and works on a prepaid balance. You add credit, then each call draws down against it, so top up before you push traffic to production.
One operational detail teams miss: treat the key like a password. Put it in an environment variable or a secret manager, never in front-end code or a public repository.
- Sign up at platform.moonshot.ai (the console also serves at platform.kimi.ai)
- Open the API keys section and create a new key
- Copy the key immediately and store it in a secret manager
- Add prepaid credit so calls do not fail on an empty balance
Ready to integrate the Kimi K3 API into your stack? Layer3 Labs sets it up with keys secured, costs controlled, and the right hosted-vs-self-hosted call for your compliance needs.
Book a ConsultationThe Kimi K3 API Base URL and Authentication
The Kimi API base URL is https://api.moonshot.ai/v1, and you authenticate with a bearer token in the request header. That header looks like Authorization: Bearer YOUR_API_KEY.
The API is OpenAI-compatible. It follows the same chat completions shape, so the chat endpoint is the base URL plus /chat/completions.
Because the format matches, most OpenAI client libraries work if you only change two things: the base URL and the API key. You do not rewrite your request logic.
Moonshot has served docs under both platform.moonshot.ai and platform.kimi.ai. Confirm the exact base URL and current model names on the platform before you ship, since vendors do adjust these.
Your First Kimi K3 API Call
You can make a first Kimi API call with a single curl command or a few lines of Python. Both send one message and print the model's reply.
Here is a minimal curl request. Replace the model value with the exact Kimi K3 model ID listed on the platform, since the ID string can change between releases.
- curl https://api.moonshot.ai/v1/chat/completions \
- -H "Authorization: Bearer $MOONSHOT_API_KEY" \
- -H "Content-Type: application/json" \
- -d '{"model": "kimi-k3", "messages": [{"role": "user", "content": "Say hello in one sentence."}]}'
Which Kimi Models Are Available Through the API
The Kimi API serves Moonshot's current Kimi models, with Kimi K3 as the newest flagship. Older Kimi K2 family models have also been offered through the same platform.
Each model has its own ID string that you pass in the model field of your request. The platform's models page is the source of truth for the exact IDs and any context-length options.
Kimi K3 is billed as a very large Mixture-of-Experts model with a long context window, which suits long documents and multi-step reasoning. See our explainer for the full picture.
Because Kimi K3 is brand new, some model IDs and thinking-mode options may still be rolling out. Call the models endpoint or check the console to see exactly what your account can use today.
- Pass the model ID in the request body's model field
- Read the platform models page for current Kimi K3 IDs and context options
- Expect a long context window for large documents and codebases
- A GET request to the /models endpoint lists what your key can call
Kimi API vs the OpenAI API: What Is the Same, What Differs
The Kimi API and the OpenAI API share the same request and response shape, so code written for one usually runs on the other with minor edits. The differences are the endpoint, the models, and the pricing.
This matters for adoption. You can trial Kimi K3 inside an existing OpenAI-based app without a rewrite, then compare quality and cost side by side.
The table below is a plain-English glance at what changes when you switch.
| Area | Kimi API (Moonshot) | OpenAI API |
|---|---|---|
| Base URL | https://api.moonshot.ai/v1 | https://api.openai.com/v1 |
| Auth | Bearer API key | Bearer API key |
| Request format | OpenAI-compatible chat completions | Chat completions (the original) |
| Models | Kimi K3 and Kimi family | GPT family |
| Vendor | Moonshot AI (China) | OpenAI (US) |
Not every advanced OpenAI feature maps one to one, so test any function calling, structured output, or streaming behavior you depend on before you cut over.
Rate Limits, Quotas, and What It Costs at a Glance
Kimi API rate limits and quotas depend on your account tier and prepaid balance, and Moonshot sets the exact numbers on its platform. Hitting a limit returns an HTTP 429 response.
Plan for 429s in code. Add retries with backoff so a short burst of traffic does not drop user requests.
On cost, Moonshot has historically priced its Kimi API well below US frontier APIs, but you should confirm the current per-token rates before you budget. We keep the full breakdown on a dedicated page.
For heavy or steady workloads, do the math on hosted API fees versus self-hosting the open weights. The cheaper path flips as your volume grows.
- Rate limits scale with your tier and balance; a 429 means slow down
- Retry 429 and 5xx responses with exponential backoff
- Check live per-token pricing before you forecast spend
- Compare API cost to self-hosting once volume is high and steady
Using the Kimi K3 API Inside Your Tools
Because the Kimi API is OpenAI-compatible, most tools that accept a custom OpenAI endpoint can drive Kimi K3 with only a base-URL and key change. That covers a lot of the stack.
The official OpenAI SDKs for Python and Node.js work as a drop-in: set base_url to the Moonshot endpoint and pass your Moonshot key. Frameworks like LangChain accept the same two overrides on their OpenAI-style client.
Many coding IDEs and assistants let you point at a custom OpenAI-compatible endpoint too. Where that setting exists, you can route Kimi K3 into your editor for code help.
You can also reach Kimi models through third-party hosts instead of Moonshot directly. Inference providers such as Groq have offered Kimi models, and Moonshot publishes open weights on Hugging Face under its moonshotai organization.
- OpenAI SDK (Python/Node): change base_url and api_key only
- LangChain: use its OpenAI-compatible client with the Moonshot base URL
- Coding IDEs: set a custom OpenAI-compatible endpoint where supported
- Hosted access: check Groq for Kimi availability, or pull weights from Hugging Face to run yourself
Common Errors, Gotchas, and When to Self-Host Instead
Most Kimi API problems trace back to four things: a bad key, an empty balance, a wrong model ID, or a rate limit. Reading the HTTP status code tells you which one you hit.
A 401 means the key is missing or wrong, and a 429 means you are over the rate limit or out of credit. A 404 or model error usually means the model ID string is stale, so recheck it against the models page.
For a US or regulated business, the bigger question is where your data goes. Calling Moonshot's hosted API sends prompts to a China-based vendor, which raises data-residency and compliance concerns for legal, health, and finance work.
When residency matters, self-hosting the open weights keeps data in your own environment. Use the hosted API for speed and low volume, and self-host once compliance, control, or scale justify the hardware. Our open-weights guide walks through that path.
- 401 Unauthorized: check the key and the Authorization header
- 429 Too Many Requests: back off, retry, or top up your balance
- 404 / model error: confirm the exact Kimi K3 model ID on the platform
- Self-host the open weights when data residency or steady volume rules out a China-hosted API
Frequently Asked Questions
- Sign up at Moonshot's developer platform, platform.moonshot.ai, then open the API keys page and generate a key. Copy it at creation time and store it in a secret manager, because the full key is shown only once. Add prepaid credit before you send production traffic.
- The Kimi API base URL is https://api.moonshot.ai/v1, and the chat endpoint is that URL plus /chat/completions. You authenticate with an Authorization: Bearer YOUR_API_KEY header. Confirm the current base URL on the platform, since Moonshot has served docs under both moonshot.ai and kimi.ai domains.
- Yes. The Kimi API follows the OpenAI chat completions request and response format, so most OpenAI client code works after you change the base URL and the API key. Advanced features like function calling or streaming are not guaranteed to match one to one, so test the specific behaviors your app needs.
- Send a POST request to https://api.moonshot.ai/v1/chat/completions with your bearer key, a model ID, and a messages array. You can do this with curl or with the OpenAI SDK by setting base_url to the Moonshot endpoint. Replace the model value with the exact Kimi K3 ID from the platform models page.
- The API serves Moonshot's current Kimi models, with Kimi K3 as the newest flagship, alongside prior Kimi K2 family models. Each model has its own ID string that you pass in the model field. Call the /models endpoint or check the console to see exactly what your account can use today.
- Moonshot has historically priced the Kimi API far below US frontier APIs, on a prepaid, per-token basis, but you should confirm current rates on the platform before budgeting. For heavy, steady workloads, compare hosted API fees against self-hosting the open weights. See our Kimi K3 pricing guide for the full breakdown.
- Yes, you can reach Kimi models through third-party hosts as well as Moonshot directly. Inference providers such as Groq have offered Kimi models, and Moonshot publishes open weights on Hugging Face so you can run them yourself. Availability of the newest Kimi K3 can lag the official API, so confirm the specific model is live before you build on it.
- Calling Moonshot's hosted Kimi API sends your prompts to a China-based vendor, which raises data-residency and compliance concerns for legal, health, and finance teams. This is not legal advice. If sensitive data cannot leave your environment, self-host the open weights instead of using the hosted API, and validate the license and security posture first.
Want the Kimi K3 API Wired Into Your Stack the Right Way?
Layer3 Labs helps businesses integrate the Kimi K3 API into real workflows, with keys secured, costs controlled, and a clear read on whether hosted or self-hosted fits your compliance needs. Book a vendor-neutral consultation.
Book a Consultation