cd /news/artificial-intelligence/moonshot-api-complete-guide-from-kim… · home topics artificial-intelligence article
[ARTICLE · art-76429] src=dev.to ↗ pub= topic=artificial-intelligence verified=true sentiment=· neutral

Moonshot API Complete Guide: From Kimi K2 to K3 and Beyond

Moonshot AI has released Kimi K3, a 2.8-trillion-parameter open-weight model leading on agentic benchmarks, and its API ecosystem is now essential for AI developers. The API is OpenAI-compatible, with pricing at $3.00 per million input tokens and $15.00 per million output tokens, undercutting comparable closed models by 50-80%. International developers can access K3 via gateways like TeamoRouter to bypass Chinese credential requirements.

read5 min views1 publishedJul 28, 2026

Moonshot AI has rapidly evolved from a promising Chinese AI lab into one of the most important model providers in the global market. With the release of Kimi K3 in July 2026 -- a 2.8-trillion-parameter open-weight model leading on agentic benchmarks -- understanding the Moonshot API ecosystem has become essential for any developer working with AI.

This guide covers everything you need to know: the evolution from K2 to K3, API setup and authentication, model selection, pricing, rate limits, code examples, and how to integrate Moonshot models into your application.

Moonshot's model lineup has evolved through several generations. Understanding the differences helps you choose the right model for your task and budget.

The Moonshot API is OpenAI-compatible, meaning you can use the standard OpenAI Python or Node.js SDK by changing the base URL:

from openai import OpenAI

client = OpenAI(
    api_key="your-moonshot-api-key",
    base_url="https://api.moonshot.ai/v1",
)

response = client.chat.completions.create(
    model="kimi-k3",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain how attention mechanisms work in transformers."},
    ],
    max_tokens=4096,
)

print(response.choices[0].message.content)
python
// Node.js example
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: 'your-moonshot-api-key',
  baseURL: 'https://api.moonshot.ai/v1',
});

const response = await client.chat.completions.create({
  model: 'kimi-k3',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'Explain how attention mechanisms work in transformers.' },
  ],
  max_tokens: 4096,
});

console.log(response.choices[0].message.content);

Direct Moonshot API access requires:

These requirements create friction for international developers. If you do not have Chinese credentials, using an API gateway is the practical alternative.

For international developers, multi-provider gateways like TeamoRouter provide the simplest path to K3 access. You use the same OpenAI-compatible SDK but with the gateway's base URL and API key:

from openai import OpenAI

client = OpenAI(
    api_key="your-teamorouter-api-key",
    base_url="https://api.teamorouter.com/v1",
)

response = client.chat.completions.create(
    model="moonshotai/kimi-k3",  # or "kimi-k3" depending on gateway naming
    messages=[
        {"role": "user", "content": "Research the latest developments in fusion energy and summarize the key breakthroughs."},
    ],
)

print(response.choices[0].message.content)

The gateway handles procurement, billing, and failover on the back end. You get a standard international API that works with any payment method.

Model Input (per 1M tokens) Output (per 1M tokens)
Kimi K3 $3.00 $15.00
Kimi K2.7 Code $1.50 $7.50
Kimi K2.6 $1.20 $6.00

K3's pricing is notably aggressive for a frontier model. Comparable closed models typically charge $10-15/M input and $30-75/M output. K3 undercuts those prices by 50-80% while matching or exceeding capability on agentic benchmarks.

Independent testers have noted that K3 currently operates at a single inference level ("max" mode) and can consume significant output tokens, especially on complex reasoning tasks. Moonshot's claim of 21% fewer output tokens compared to K2.6 applies to the architecture but real-world usage varies. Budget accordingly -- a complex agentic task with web browsing and multi-step reasoning can easily consume 10,000-50,000 output tokens.

Moonshot's API rate limits are not publicly documented in detail, but community reports suggest:

For production workloads, the reliability consideration extends beyond rate limits:

These considerations make API gateways with automatic failover particularly valuable for production use of K3, as covered in the integration patterns section below.

Use Case Recommended Model Reason
Autonomous web-browsing agents K3 #1 BrowseComp, built for multi-step web research
Complex multi-file coding projects K3 1M context handles large codebases; #1 Automation Bench
Document-heavy analysis (legal, financial) K3 1M context fits entire documents; AA-Briefcase Elo 1543
Simple single-turn coding tasks K2.7 Code Sufficient capability at half the price of K3
Cost-sensitive high-volume chat K2.6 Lowest cost; adequate for straightforward Q&A
Chinese-language applications K3 or K2.6 All Kimi models have strong Chinese-language performance
Agentic task automation K3 Automation Bench leader; purpose-built for multi-step execution

The Moonshot API supports function calling (tool use) through the standard OpenAI interface:

tools = [
    {
        "type": "function",
        "function": {
            "name": "search_documentation",
            "description": "Search the project documentation for relevant information",
            "parameters": {
                "type": "object",
                "properties": {
                    "query": {
                        "type": "string",
                        "description": "The search query"
                    }
                },
                "required": ["query"]
            }
        }
    }
]

response = client.chat.completions.create(
    model="kimi-k3",
    messages=[
        {"role": "system", "content": "You are a coding assistant with access to documentation search."},
        {"role": "user", "content": "How do I configure Redis caching in the application?"}
    ],
    tools=tools,
    tool_choice="auto",
)

K3's strong tool-use performance is a key reason it leads on agentic benchmarks. The model is particularly good at deciding when to invoke tools, interpreting tool results, and chaining multiple tool calls into coherent multi-step workflows.

K3 supports streaming responses through the standard stream=True

parameter:

stream = client.chat.completions.create(
    model="kimi-k3",
    messages=[{"role": "user", "content": "Write a detailed analysis of quantum computing's impact on cryptography."}],
    stream=True,
)

for chunk in stream:
    if chunk.choices[0].delta.content is not None:
        print(chunk.choices[0].delta.content, end="")

For long-running agentic tasks, consider implementing a polling or callback pattern rather than holding open a streaming connection, especially given the latency variability of China-based infrastructure.

Your App → Moonshot API (api.moonshot.ai)

Best for developers with Chinese credentials who only need K3 and can tolerate occasional downtime.

Your App → TeamoRouter → Moonshot API (primary)
                      → Fallback Model (if K3 is unavailable)

You get K3 access without Chinese credentials, plus automatic failover and multi-model access through a single integration.

Your App → TeamoRouter → K3 (for research/browsing tasks)
                      → Claude (for code generation)
                      → GPT (for creative/general tasks)

Route each task to the best model for that job. This is the pattern that maximizes performance-per-dollar across a diverse workload.

Moonshot has established a pattern of rapid iteration -- K2.5, K2.6, K2.7 Code, and K3 all released within roughly 18 months. The open-weight release of K3 suggests Moonshot is committed to the open model approach, which means the community can expect:

For developers, the practical takeaway is to adopt K3 through a flexible integration layer -- an API gateway or routing platform -- so that when Moonshot releases K3.5 or K4, you can adopt it immediately without changing your application code.

TeamoRouter gives you instant access to Kimi K3 through a standard OpenAI-compatible API. No Chinese phone number, no Alipay, no separate accounts for every model. One API key unlocks K3 alongside Claude, GPT, Gemini, DeepSeek, and 200+ other models.

Start building at teamorouter.com.

── more in #artificial-intelligence 4 stories · sorted by recency
── more on @moonshot ai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/moonshot-api-complet…] indexed:0 read:5min 2026-07-28 ·