DEV Community

TeamoRouter
TeamoRouter

Posted on

How to Access Kimi K3 API: Pricing, Rate Limits, and Setup Guide

Quick Answer

The Kimi K3 API is OpenAI-compatible, costs $3.00/M input tokens (cache miss), $0.30/M input tokens (cache hit), and $15.00/M output tokens, and runs on https://api.moonshot.ai/v1 (international) or https://api.moonshot.cn/v1 (China). The model ID is kimi-k3. A typical single API call costs about $0.007. This guide covers pricing in detail, rate limits, setup in Python and Node.js, caching optimization, and how to route through a stable gateway for production reliability.

Kimi K3 API Pricing Breakdown

K3's pricing marks a significant shift for Moonshot AI — it is substantially more expensive than previous Kimi models, placing it in the same tier as Western frontier models while remaining cheaper than them on a per-task basis.

Per-Token Pricing

Token Type Price per 1M Tokens (USD) Price per 1M Tokens (CNY)
Input (cache miss) $3.00 ¥20
Input (cache hit) $0.30 ¥2
Output $15.00 ¥100

How This Compares

Model Input (Cache Miss) Output
Kimi K3 $3.00 $15.00
GPT-5.6 Sol $5.00 $30.00
Claude Fable 5 $10.00 $50.00
DeepSeek V4-Pro ~$0.18 ~$0.90
Qwen3.7-Max ~$1.07 ~$5.36

K3 sits in an interesting position: it is the most expensive model ever released by a Chinese AI lab (output pricing is roughly 16.7x DeepSeek V4-Pro), yet still 50-70% cheaper than the top Western closed-source models on a per-token basis.

The Cache Advantage

The headline numbers don't tell the full story. K3's architecture is purpose-built for high cache hit rates. Moonshot's Mooncake serving infrastructure reportedly achieves over 90% cache hit rates in coding-heavy agent workloads. This means that in practice, most of your input tokens are billed at the cached rate of $0.30/M — a 90% discount.

Third-party testing by Artificial Analysis found that despite the high per-token output price, K3's average per-task cost (~$0.94) is comparable to GPT-5.6 Sol (~$1.04) and roughly half of Claude Opus 4.8 (~$1.80). The model simply consumes fewer total tokens to complete equivalent tasks. On the DeepSWE benchmark, K3's cost per rollout was $4.65 — compared to $13.41 for Claude Fable 5 and $8.37 for GPT-5.6 Sol.

Real-World Cost Estimates

Here is what typical usage patterns cost with K3:

Scenario Tokens In Tokens Out Cost
Single chat message ~500 ~300 ~$0.006
Code generation task ~2,000 ~1,500 ~$0.029
Full agent coding session ~50,000 ~20,000 ~$0.45 (with caching)
Large repo analysis (1M context) ~500,000 ~5,000 ~$0.23 (with caching)
Heavy daily developer usage ~2M ~500K ~$13.50 (with caching)

These are estimates — your actual costs depend on cache hit rates, task complexity, and output verbosity.

Rate Limits and Access Restrictions

Moonshot AI has not published explicit RPM (requests per minute) or TPM (tokens per minute) caps, but several access constraints are known:

Consumer Subscription Pause

Within 48 hours of K3's July 16, 2026 launch, Moonshot paused new consumer (C-end) subscriptions. Server load had reached capacity, and the existing GPU cluster could not handle the exponential growth in call volume. Available compute was prioritized for existing paid users. As of late July 2026, this restriction is gradually being lifted as additional capacity comes online.

API Parameter Restrictions

At launch, several parameters are locked:

  • Reasoning effort: Only reasoning_effort="max" is available. You cannot set it to low or medium to reduce token consumption. Lighter modes are promised for future releases.
  • Temperature, top_p, penalty parameters: All fixed. Developers must omit these from API requests — including them may cause errors or be silently ignored.
  • Public image URLs: Not supported through the API at launch. Use base64-encoded images or file uploads for vision inputs.

Throughput Observations

Third-party gateway data from Vercel shows two performance tiers:

Variant Throughput Latency
Kimi K3 (standard) ~33-35 tokens/sec ~5.5-6.3s
Kimi K3 Fast ~117 tokens/sec ~2.8s

The standard tier is noticeably slower than GPT-5.6 Sol and Claude Fable 5. If latency matters for your use case, target the Fast variant or implement streaming to hide the delay.

Python Setup (Under 5 Minutes)

Kimi K3 uses the OpenAI SDK. If you have used the OpenAI API before, switching to K3 requires changing exactly three values.

Step 1: Install the SDK

python -m pip install --upgrade "openai>=1.0"
Enter fullscreen mode Exit fullscreen mode

Step 2: Get Your API Key

  1. Go to platform.moonshot.ai (international) or platform.moonshot.cn (China).
  2. Sign in or create an account.
  3. Navigate to the API Keys page.
  4. Click Create to generate a new key (it starts with sk-).
  5. Copy the key immediately — you will not be able to see it again after closing the page.
  6. Add a small balance (a few dollars is enough to start).

Step 3: Set Up Your Environment

export MOONSHOT_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Enter fullscreen mode Exit fullscreen mode

Step 4: Write Your First Call

import os
from openai import OpenAI

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

completion = client.chat.completions.create(
    model="kimi-k3",
    messages=[
        {"role": "system", "content": "You are a helpful coding assistant."},
        {"role": "user", "content": "Write a Python function that parses a CSV file and returns summary statistics."},
    ],
    max_completion_tokens=1200,
)

print(completion.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

Step 5: Add Streaming

For a real-time typewriter effect:

stream = client.chat.completions.create(
    model="kimi-k3",
    messages=[{"role": "user", "content": "Explain the Kimi Delta Attention mechanism."}],
    stream=True,
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
Enter fullscreen mode Exit fullscreen mode

Node.js Setup

For JavaScript/TypeScript developers:

npm install openai
Enter fullscreen mode Exit fullscreen mode
import OpenAI from "openai";

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

const completion = await client.chat.completions.create({
  model: "kimi-k3",
  messages: [
    { role: "user", content: "Write a React component for a search bar with debounce." },
  ],
  max_completion_tokens: 1500,
});

console.log(completion.choices[0].message.content);
Enter fullscreen mode Exit fullscreen mode

Streaming in Node.js:

const stream = await client.chat.completions.create({
  model: "kimi-k3",
  messages: [{ role: "user", content: "Explain REST vs GraphQL." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || "");
}
Enter fullscreen mode Exit fullscreen mode

Migrating from OpenAI in 30 Seconds

If you already have code using the OpenAI SDK, switch to K3 with three changes:

# Before (OpenAI)
client = OpenAI(api_key="sk-openai-xxx")
model = "gpt-4o"

# After (Kimi K3)
client = OpenAI(
    api_key="sk-moonshot-xxx",                        # 1. New API key
    base_url="https://api.moonshot.ai/v1",            # 2. New base URL
)
model = "kimi-k3"                                      # 3. New model ID
Enter fullscreen mode Exit fullscreen mode

Remove any temperature, top_p, or penalty parameters from your request — K3 does not support them at launch. Also remove reasoning_effort unless you are explicitly targeting "max".

Optimizing for Cost: Context Caching

K3's most powerful cost-saving feature is context caching. When you send repeated requests with overlapping context (common in agentic workflows), the system reuses cached computations for shared prefix tokens, billing them at the $0.30/M rate instead of $3.00/M.

To maximize cache hits:

  1. Put static content first. System prompts, tool definitions, and project context should appear at the beginning of your message sequence. Changing only the last user message preserves the shared prefix.
  2. Keep system prompts stable. Avoid dynamic timestamps, random IDs, or session-specific data in your system prompt. Every change to the prefix invalidates the cache.
  3. Use consistent message structure. If your agent always uses the same tool definitions and project rules in the same order, cache hit rates can exceed 90%.
  4. Batch similar tasks. Run related queries close together in time. The cache persists for a limited window after the last request.

The difference between good and bad caching discipline can be a 5-10x factor in your effective input cost.

Production Considerations: The Case for an API Gateway

Calling the Moonshot API directly works fine for development and low-traffic use cases. For production workloads, however, a direct dependency introduces several risks:

  • Single-provider risk. If Moonshot's API experiences an outage or rate-limiting event, your application stops working. This happened within 48 hours of K3's launch when demand overwhelmed the GPU cluster.
  • No failover. Direct API calls have no automatic fallback. If api.moonshot.ai is unreachable, your requests fail.
  • Scaling complexity. Managing API keys, monitoring usage, and handling retry logic across multiple models and providers adds operational overhead.

TeamoRouter addresses these issues as a stable API gateway layer. Instead of calling Moonshot directly, your application sends requests to TeamoRouter's endpoint, which handles:

  • Automatic failover. If the primary K3 endpoint becomes unavailable, traffic is seamlessly routed to alternative endpoints.
  • Load balancing. Requests are distributed across multiple provider channels to avoid hitting rate limits.
  • Unified billing. One API key, one bill — regardless of how many underlying providers you use.
  • Health monitoring. Continuous probing of all upstream providers so failing endpoints are detected and bypassed before your requests hit them.

For teams building production applications on K3, routing through a gateway like TeamoRouter turns API reliability from something you manage into something you get by default.

Common Pitfalls and Troubleshooting

"Model not found" errors

Make sure your model ID is kimi-k3 (lowercase, hyphenated). kimi_k3, kimik3, or Kimi-K3 will not work.

Authentication failures

Verify your API key starts with sk- and that you have added funds to your account. An empty balance will produce authentication-like errors.

Temperature/top_p errors

Remove temperature, top_p, frequency_penalty, and presence_penalty from your API calls. K3 ignores or rejects these at launch.

Slow responses

K3's standard tier generates ~33-35 t/s. This is architectural — the recurrent KDA state computation adds overhead. Use streaming to make the experience feel faster, and consider the Fast tier (~117 t/s) for latency-sensitive applications.

Vision/image uploads failing

At launch, only base64-encoded images and file uploads work. Do not pass public URLs in image_url fields — they will fail.

Rate limiting

If you receive 429 errors, you are hitting rate limits. Reduce concurrency, add exponential backoff, or route through a gateway like TeamoRouter that distributes load across multiple provider endpoints.

Quick Reference Card

Base URL (International):  https://api.moonshot.ai/v1
Base URL (China):          https://api.moonshot.cn/v1
Model ID:                  kimi-k3
SDK:                       openai (Python), openai (Node.js)
Input (cache miss):        $3.00 / 1M tokens
Input (cache hit):         $0.30 / 1M tokens
Output:                    $15.00 / 1M tokens
Context window:            1,048,576 tokens
Key format:                sk-...
API key page:              platform.moonshot.ai → API Keys
Enter fullscreen mode Exit fullscreen mode

Next Steps

  1. Start small. Get an API key, make a few test calls, and understand the pricing before integrating K3 into a production pipeline.
  2. Design for caching. Structure your prompts and system messages to maximize cache hit rates. The 90% discount on cached input is K3's biggest cost advantage.
  3. Plan for reliability. For anything beyond experimentation, route K3 traffic through TeamoRouter to get automatic failover and multi-provider resilience without changing your application code. One endpoint, stable access to K3 and hundreds of other models, with health monitoring and failover built in.

Top comments (0)