Skip to main content
API Key Setup7 min readPublished: 2026-07-29Updated: 2026-07-29

How to Get a Kimi API Key (2026 Step-by-Step Guide)

Kimi K3 by Moonshot AI offers ultra-long context and strong reasoning. Learn how to register, get your API key, understand pricing, and make your first request with code examples.

What Is Kimi K3?

Kimi K3 is the flagship language model from Moonshot AI (月之暗面), one of China's leading AI startups. It is specifically designed for ultra-long context processing, supporting up to 256K tokens in a single request — enough to process an entire book or a large codebase in one call.

Kimi K3 excels at Chinese language understanding, long-document Q&A, and multi-turn conversations that require maintaining context over extended interactions. It also performs strongly on reasoning tasks and code generation, making it a versatile choice for developers building applications that need to process large amounts of text.

The Kimi API is OpenAI-compatible, which means you can use the standard OpenAI SDK with a different base URL. This makes migration from OpenAI or other compatible APIs straightforward.

Step 1: Register on the Moonshot AI Platform

To use the Kimi API, you need to register on the Moonshot AI developer platform at platform.moonshot.cn. The platform requires a phone number for verification — both Chinese and some international numbers are supported.

Click 'Register' on the platform homepage, enter your phone number, and complete the SMS verification. After verification, fill in your basic information to complete the registration. The entire process typically takes under two minutes.

If you are an international developer and encounter issues with phone verification, consider using a Chinese colleague's number or contacting Moonshot's support for alternative registration methods.

Step 2: Generate Your Kimi API Key

After logging in to the Moonshot platform, navigate to the 'API Key Management' section in the dashboard. Click 'Create API Key', give it a descriptive name so you can identify it later, and the key will be generated.

Copy the API key immediately and store it securely. Like most API providers, Moonshot only displays the full key once at creation time. If you lose it, you will need to create a new one.

Store the key in an environment variable or a secrets management system. Never hardcode API keys in source files or commit them to version control.

  • Log in to platform.moonshot.cn
  • Navigate to 'API Key Management' in the dashboard
  • Click 'Create API Key' and name it descriptively
  • Copy the key immediately (shown only once)
  • Store in an environment variable or secrets manager

Step 3: Understand Kimi API Pricing

Moonshot uses a pay-per-token pricing model with separate rates for input and output tokens. The Kimi K3 model is competitively priced, especially considering its long-context capabilities — processing 256K tokens in a single call is more cost-effective than chunking and making multiple requests with shorter-context models.

New users may receive free trial credits upon registration, which is enough for initial testing. For continued usage, you need to add credits to your account. The platform supports Alipay and WeChat Pay for payments.

Moonshot also offers prompt caching discounts for repeated context, which can reduce costs significantly for applications that process the same long documents across multiple requests. Check the official pricing page for current rates.

Step 4: Make Your First Kimi API Request

The Kimi API is OpenAI-compatible, so you can use the OpenAI Python SDK with a different base URL. Here is a minimal example showing how to call the Kimi K3 model:

python
from openai import OpenAI

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

response = client.chat.completions.create(
    model="kimi-k3-0905-preview",
    messages=[
        {"role": "user", "content": "Hello, what can you do?"}
    ]
)

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

Minimal Kimi API call using the OpenAI Python SDK

javascript
import OpenAI from "openai";

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

const response = await client.chat.completions.create({
  model: "kimi-k3-0905-preview",
  messages: [
    { role: "user", content: "Hello, what can you do?" },
  ],
});

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

Minimal Kimi API call using the OpenAI JavaScript SDK

Kimi K3 Key Features

Kimi K3 stands out in several areas that make it particularly suitable for certain use cases. Understanding these features helps you decide when to choose Kimi over other models.

The ultra-long context window is Kimi K3's defining feature. With 256K tokens, you can feed entire documents, codebases, or conversation histories into a single request without chunking or summarization. This is especially valuable for legal document analysis, code review, and research tasks.

Kimi K3 also features strong reasoning capabilities, performing well on mathematical and logical benchmarks. Its Chinese language understanding is among the best of all commercial LLMs, making it ideal for applications targeting Chinese-speaking users.

  • Ultra-long context: 256K token window for processing entire documents in a single call
  • Strong reasoning: competitive performance on math, logic, and code benchmarks
  • Chinese language excellence: top-tier Chinese understanding and generation
  • OpenAI-compatible: use standard OpenAI SDK with a different base URL
  • Prompt caching: discounts for repeated long-context inputs

FAQ

Is the Kimi API free?

The Kimi API is not free, but new users may receive free trial credits upon registration. The paid pricing is competitive, especially for long-context tasks where Kimi's 256K token window reduces the need for multiple chunked requests.

What is the context window size of Kimi K3?

Kimi K3 supports a 256K token context window, which is one of the largest among commercial LLM APIs. This allows you to process approximately 180,000 words — equivalent to a full-length novel or a large codebase — in a single API call.

Can I use the OpenAI SDK with the Kimi API?

Yes. The Kimi API is fully OpenAI-compatible. Set the base URL to https://api.moonshot.cn/v1 and use your Kimi API key. All standard OpenAI SDK methods work without modification.

Can international developers use the Kimi API?

Moonshot's platform supports some international phone numbers for registration. However, payment is primarily through Alipay and WeChat Pay. International developers may need assistance from a China-based partner for payment. The API itself is globally accessible once you have a valid key.

How does Kimi K3 compare to DeepSeek?

Kimi K3 has a larger context window (256K vs DeepSeek's 128K) and is stronger in Chinese language tasks and long-document processing. DeepSeek offers lower per-token pricing and strong reasoning with its R1 model. For a detailed comparison of Chinese AI platforms, see our complete China AI API guide.

Related Providers

Sources