Kimi (Moonshot AI) API key setup
Published 2026-10-11 · Updated 2026-10-20
Moonshot’s Kimi keys look familiar: sk- plus a long alphanumeric body, roughly 52 characters in total. The part that confuses people isn’t the key, it’s which endpoint to point it at.
Two platforms, two base URLs
- International:
https://api.moonshot.ai/v1, keys fromplatform.moonshot.ai/platform.kimi.ai - China:
https://api.moonshot.cn/v1, keys fromplatform.moonshot.cn
A key only works on the platform that issued it. A 401 from api.moonshot.ai on a .cn key is the classic symptom.
Setup
export MOONSHOT_API_KEY="sk-..."
curl https://api.moonshot.ai/v1/models \
-H "Authorization: Bearer $MOONSHOT_API_KEY"
from openai import OpenAI
import os
client = OpenAI(
api_key=os.environ["MOONSHOT_API_KEY"],
base_url="https://api.moonshot.ai/v1",
)
resp = client.chat.completions.create(
model="kimi-k3",
messages=[{"role": "user", "content": "Say hello"}],
)
print(resp.choices[0].message.content)
The Kimi Code keys
Kimi’s coding subscription issues a different credential: sk-kimi-..., used against https://api.kimi.com/coding/v1. It’s a separate product from the open platform keys: same account family, different billing.
Notes
- Model names:
kimi-k3,kimi-latest, and the oldermoonshot-v1-8k/32k/128kaliases. The/modelslist is the source of truth for your tier. - Top-up gates: flagship models sometimes require at least one successful recharge before they’ll respond, a valid key can still get “insufficient permission” style errors on K3 until the account has paid once.
- Reserved names in tools: some editors treat model ids starting with
kimi-as built-ins and won’t route them to your custom base URL. Rename or pick a non-colliding alias in the tool’s config.
Keep MOONSHOT_API_KEY in the environment, match it to the right region, and the rest behaves like any OpenAI-compatible API.