← Blog

How to Create a Moonshot AI API Key: Step-by-Step

2026-09-06 · 5 min read · SubToAPI Team

Moonshot AI is the company behind the Kimi family of models, and if you want to call them programmatically you need an API key from the Moonshot AI open platform. Creating one takes about five minutes: sign up, verify your account, add billing, and generate a key from the API keys page in the console.

This guide walks through the full process, including the platform region you should pick, how to test your key with a real request, and what to do if you need to combine Moonshot AI with other model providers behind a single interface.

Step 1: Create a Moonshot AI Platform Account

  1. Go to the Moonshot AI open platform (platform.moonshot.cn for the mainland China platform, or platform.moonshot.ai for the international version, depending on which region you're targeting).
  2. Sign up with an email address or phone number, depending on the platform version.
  3. Verify your account through the confirmation email or SMS code.
  4. Complete any required identity or organization verification — this step varies by region and account type.

Pick the platform that matches where you'll actually be sending traffic from and which data residency requirements apply to your use case. The two platforms have separate accounts, billing, and API keys — a key from one won't work on the other's endpoint.

Step 2: Add Billing Information

Moonshot AI's API is metered by token usage, so you'll need to add a payment method or top up a prepaid balance before you can make live calls. Most accounts get a small amount of free trial credit, but production usage requires funded billing.

  1. Navigate to the billing or account balance section of the console.
  2. Add a payment method or top up your balance directly.
  3. Check the current pricing page for the specific Kimi model you plan to use — pricing differs across model sizes and context window options.

Step 3: Generate the API Key

  1. In the console, find the API Keys section (usually under account settings or a dedicated developer menu).
  2. Click Create new key.
  3. Give it a descriptive name — something like kimi-prod-backend or kimi-dev-test — so you can identify it later if you're managing several keys across environments.
  4. Copy the key immediately. Like most model provider consoles, Moonshot AI shows the full key value only once at creation time.

Store the key in an environment variable rather than hardcoding it:

export MOONSHOT_API_KEY="sk-your-key-here"

Never commit this value to source control. If a key does leak into a repository or log file, revoke it from the console and generate a new one immediately.

Step 4: Make Your First Request

Moonshot AI's API is designed to be broadly compatible with the OpenAI chat completions format, which makes it easy to test with a simple curl call:

curl https://api.moonshot.cn/v1/chat/completions \
  -H "Authorization: Bearer $MOONSHOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "moonshot-v1-8k",
    "messages": [
      { "role": "user", "content": "Summarize the main idea of transformers in two sentences." }
    ]
  }'

A successful response returns a JSON object with a choices array containing the model's reply, plus token usage counts you can use for cost tracking. If you get a 401, double-check that the key is active and that you're pointing at the correct regional endpoint.

Step 5: Set Usage Limits and Rotate Keys

Once the key works, go back into the console and:

When You Need More Than One Provider

A single Moonshot AI key works fine for a project built exclusively on Kimi models. But many teams end up mixing providers — Kimi for cost-efficient long-context tasks, Claude for tool use and coding accuracy, maybe another model for a specific benchmark strength. Managing separate API keys, separate billing dashboards, and separate SDKs for each one adds real operational overhead: different rate-limit behaviors, different streaming formats, different auth schemes.

If your stack already uses Claude, SubToAPI turns your existing Claude access into a standard HTTPS API with its own sub_live_... application keys, so you get one consistent interface — streaming, tool use, usage metadata, and team seats — instead of stitching together provider-specific SDKs. It doesn't replace your Moonshot AI key or touch Moonshot's platform; it just means the Claude side of a multi-provider setup looks and behaves the same as everything else in your codebase.

Getting started takes the same shape as Moonshot's own setup: sign up, generate a key, and send your first request per the quickstart. The messages endpoint covers basic request/response handling, streaming covers token-by-token output, and tools documents function calling. Plans start at €9/month on the Solo tier, with Team and Scale tiers for shared seats — see pricing for details.

Questions

Do I need a separate Moonshot AI account for the international and China platforms? Yes. platform.moonshot.cn and platform.moonshot.ai are separate systems with independent accounts, billing balances, and API keys. A key generated on one platform will not authenticate against the other's endpoint.

Is Moonshot AI's API compatible with OpenAI's SDK? Largely yes — the request and response format for chat completions closely mirrors OpenAI's schema, so many existing OpenAI SDK clients can point at Moonshot's endpoint with only the base URL and API key changed. Always check the current docs for edge-case differences in parameters.

What should I do if my Moonshot AI key gets exposed? Revoke it immediately from the API keys section of the console and generate a replacement. Update any environment variables, CI secrets, or config files referencing the old key, and check your usage logs for unexpected activity during the exposure window.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →