On this page
- What Is Kimi K2?
- Where Kimi K2 Is Available: Free Chat and Paid APIs
- Kimi K2 Hosted API Pricing
- Your First Kimi K2 API Call (OpenAI-Compatible)
- Kimi K2 in Claude Code, Cline & Aider (Anthropic-Compatible)
- Connect Kimi K2 to OpenClaw (Free AI Agent)
- Kimi K2 vs Other Free AI APIs
- Frequently Asked Questions
Kimi K2 is a family of open-weights LLMs from Moonshot AI, released with downloadable weights under a Modified MIT license. Third parties can host it, but open weights do not guarantee a free hosted endpoint. The line moves fast (K2, K2.5, K2.6, K2.7 Code), so treat every price and rate limit below as a snapshot and confirm the live number before budgeting.
Everything here is grounded in Moonshot's docs at platform.kimi.ai, the technical report on arXiv (2507.20534), and the MoonshotAI/Kimi-K2 repo.
What Is Kimi K2?
Kimi K2 is the developer-facing model line behind Moonshot's Kimi assistant. Three things make it stand out:
- Mixture-of-Experts at frontier scale. The original K2 is an MoE model with roughly 1 trillion total parameters but only ~32 billion active per token — giant-model knowledge at closer to 32B-dense inference cost.
- Built for agents. Trained specifically for tool calling, multi-step reasoning, and long autonomous coding sessions, not just chat benchmarks.
- Genuinely open weights. Checkpoints ship on Hugging Face under a Modified MIT license — inspect, run offline, deploy commercially. Hosted API access is priced separately.
Benchmarks
From Moonshot's technical report, the original Kimi K2 under a non-thinking evaluation:
| Benchmark | Kimi K2 (original) | What it measures |
|---|---|---|
| SWE-bench Verified | 65.8% (single-attempt, bash/editor tools) | Real GitHub bug-fix tasks — agentic coding |
| Tau2-bench | 66.1 | Tool-use in multi-turn agent settings |
| ACEBench (en) | 76.5 | Function/tool calling accuracy |
Later flagships K2.5 and K2.6 report substantially higher SWE-bench scores (Moonshot cites K2.6 around the low-80s percent), and K2.7 Code is a coding-specialized variant. Since newest-release numbers are still settling, anchor on the peer-published 65.8% and treat newer scores as "meaningfully better, verify against the current model card." The takeaway: K2 is a frontier-class open model that's especially strong at coding and tool use.
Where Kimi K2 Is Available: Free Chat and Paid APIs
Way 1 — OpenRouter (the :free variant is gone)
OpenRouter's live model catalog listed its Kimi models with nonzero input and output prices on 2026-10-24. The old moonshotai/kimi-k2:free endpoint is not in that catalog. The paid model ID in the example below is not a free route; for $0 inference, choose a model that currently appears in OpenRouter's free list.
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["OPENROUTER_API_KEY"],
base_url="https://openrouter.ai/api/v1",
)
resp = client.chat.completions.create(
model="moonshotai/kimi-k2", # paid; the :free variant was retired
messages=[
{"role": "system", "content": "You are a concise coding assistant."},
{"role": "user", "content": "Write a Python function that flattens a nested list."},
],
)
print(resp.choices[0].message.content)
Because it's OpenAI-compatible, the same code talks to any other OpenRouter model — swap the model string for Gemini, DeepSeek, or Llama.
Way 2 — Cloudflare Workers AI (paid access for Kimi)
Cloudflare offers free Workers AI usage for eligible models, but that allowance does not cover the current Kimi models. Its Kimi K2.6 and K2.7 Code pages explicitly require a Workers Paid plan or prepaid AI Gateway credits. The older K2.5 model was deprecated and aliased to K2.6, according to Cloudflare's changelog. If you have paid access, use the model's current documented ID rather than the obsolete @cf/moonshotai/kimi-k2 path:
curl "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/ai/run/@cf/moonshotai/kimi-k2.6" \
-H "Authorization: Bearer $CF_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "user", "content": "Explain the difference between a process and a thread."}]}'
This request uses paid Kimi access. A general Workers AI free allocation is not evidence that every model in its catalog can run on a free account.
Way 3 — kimi.com (chat, no API)
If you don't need programmatic access, kimi.com is Moonshot's chat product. Check its current no-cost limits in the app; chat access does not grant an API key or make the hosted Kimi API free.
Bonus — self-host the open weights
Weights are public on Hugging Face, so you can run K2 with vLLM or SGLang and expose your own API. The license is free; the hardware is the catch — a 1T-parameter MoE needs serious multi-GPU memory. This is not a free hosted API.
Kimi K2 Hosted API Pricing
The official Moonshot API is inexpensive by frontier standards — pay-as-you-go on a prepaid balance, USD per 1M tokens. As of mid-2026 the shape looks like this; confirm live numbers at platform.kimi.ai/docs/pricing:
| Model | Context | Input / 1M | Output / 1M | Best for |
|---|---|---|---|---|
| kimi-k2.6 | ~256K | ~$0.95 | ~$4.00 | Flagship general + agentic work |
| kimi-k2.5 | ~256K | ~$0.60 | ~$3.00 | Cheaper capable general model |
| kimi-k2.7-code | large | see docs | see docs | Agentic coding specialist |
| moonshot-v1-* | 8K–128K | see docs | see docs | Legacy general models |
- Automatic context caching. Repeated prompt prefixes are billed at a steep discount on cache hits — roughly $0.10–$0.16 per 1M input depending on model, versus the full cache-miss rate. A large saving for agents that resend a big system prompt every turn.
- New-account activation. Moonshot typically asks for a prepaid balance to activate API access. There's no verified ongoing free token grant. For no-cost chat, check kimi.com; for an API, budget for hosted usage or your own hardware.
Your First Kimi K2 API Call (OpenAI-Compatible)
The base URL is https://api.moonshot.ai/v1 and the request/response shapes match the OpenAI Chat Completions API — if your code already calls OpenAI, you change two lines. Get a key at platform.kimi.ai (top up the activation minimum, open API Keys). The key is shown once; store it in .env, never commit it.
from openai import OpenAI
import os
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": "Write a Python function that returns the nth Fibonacci number iteratively."},
],
)
print(response.choices[0].message.content)
The same client works for streaming (stream=True) and JSON-mode (response_format={"type": "json_object"}), exactly as with OpenAI. Model IDs and prices change per release — call GET /v1/models before hardcoding a name.
Kimi K2 in Claude Code, Cline & Aider (Anthropic-Compatible)
This is K2's killer developer feature. Moonshot exposes an Anthropic-compatible endpoint at https://api.moonshot.ai/anthropic, so you can point Claude Code (and any Anthropic-API tool) at Kimi K2 with two environment variables and run a top-tier open coding agent instead of paying frontier prices:
# Point Claude Code at Kimi K2
export ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic"
export ANTHROPIC_AUTH_TOKEN="$MOONSHOT_API_KEY"
export ANTHROPIC_MODEL="kimi-k2.6"
# now just run claude as normal
claude
Or persist the same three keys under "env" in ~/.claude/settings.json. For tools that speak the OpenAI shape — Cline, Aider, Continue.dev, OpenWebUI — use https://api.moonshot.ai/v1 with a Kimi model ID instead. Pair either with automatic context caching and a full day of agentic coding costs a fraction of a frontier model.
Connect Kimi K2 to OpenClaw (Free AI Agent)
OpenClaw is an open-source agent platform that works with any OpenAI-compatible endpoint, so Kimi K2 drops in as a one-step provider. Install, onboard, and choose Custom OpenAI-compatible when prompted:
npm install -g openclaw@latest
openclaw onboard
Enter the base URL (OpenRouter, now paid since the :free variant was retired, or the official endpoint for the full flagship + caching), paste your key, and pick a Kimi model. K2's large context lets the agent hold a real codebase in working memory, and its agentic training makes it strong at the multi-step tool loops OpenClaw is built around.
Kimi K2 vs Other Free AI APIs
| Feature | Kimi K2 (Moonshot) | DeepSeek | GLM (Z.ai) | Google Gemini |
|---|---|---|---|---|
| Free API path | None verified (2026-10-24); Cloudflare Kimi requires paid access | Low-cost paid (promos) | 3 free Flash models | True free tier, no card |
| Payment to start (hosted API) | Paid plan or prepaid balance | Yes | No | No |
| Open weights | Yes (Modified MIT) | Yes (MIT) | Partly | No |
| Flagship context | ~256K | 128K | ~200K | 1M |
| Agentic/coding strength | Very high | High | High (coding Flash) | High |
| OpenAI-compatible | Yes | Yes | Yes | Yes (compat endpoint) |
| Anthropic-compatible (Claude Code) | Yes | Via proxy | Yes | No |
The honest read: if your requirement is a no-card hosted API, choose a provider with a confirmed free model, such as Gemini or GLM Flash. Choose Kimi K2 for its open weights and agentic coding strengths when you can pay for hosted inference or supply your own hardware. OpenRouter, Moonshot direct, and Cloudflare's current Kimi endpoints are not verified free API paths.
Frequently Asked Questions
Is the Kimi K2 API free?
Moonshot's first-party API (api.moonshot.ai) is prepaid pay-as-you-go. OpenRouter's live catalog lists its Kimi models at nonzero prices, and Cloudflare's current Kimi model pages require paid access. We found no verified free hosted Kimi K2 API on 2026-10-24. The chat app and self-hosted weights are separate options.
Do I need a credit card to use Kimi K2?
The chat app may be usable without a payment method, subject to its current limits. Hosted Kimi API access on Moonshot, OpenRouter or Cloudflare is paid; check each provider's current billing requirements before signing up.
Can I run Kimi K2 inside Claude Code?
Yes — one of its most popular uses. Set ANTHROPIC_BASE_URL to https://api.moonshot.ai/anthropic, ANTHROPIC_AUTH_TOKEN to your Moonshot key, and ANTHROPIC_MODEL to a Kimi model, then run Claude Code normally. It keeps Claude Code's interface while running Kimi K2's coding-tuned weights underneath.
Are Kimi K2's weights really open?
Yes. Moonshot publishes the checkpoints on Hugging Face under a Modified MIT license, so you can inspect, fine-tune, self-host, and deploy commercially — the same openness that lets third parties offer free hosted endpoints.