Kimi API Authentication — API Key Setup and Security Guide
Quick Answer
Kimi API authentication uses bearer tokens. Generate your kimi api key at
platform.moonshot.cn,
then include it in the Authorization: Bearer your-key header with every request.
One key works for all Kimi models. Keys are shown only once — store them securely.
What is Kimi API Authentication
Kimi API authentication follows the industry-standard bearer token pattern, identical to OpenAI's approach. Every API request must include your kimi api key in the HTTP Authorization header. Without valid authentication, all requests return a 401 Unauthorized error.
How to Authenticate with Kimi API
Follow these steps to set up kimi api authentication:
- Sign up at platform.moonshot.cn
- Verify your email address
- Navigate to API Keys in your dashboard
- Click "Generate New Key" and copy it immediately
- Store securely in environment variables (never in code)
Authorization: Bearer sk-your-kimi-api-key-here import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("KIMI_API_KEY"),
base_url="https://api.moonshot.cn/v1"
) API Key Security Best Practices
- Never hardcode your kimi code api key in source code or commit it to version control
- Use environment variables — store keys in
.envfiles excluded from git - Rotate keys regularly — generate new keys monthly and revoke old ones
- Use separate keys for development and production environments
- Monitor usage — check your Moonshot dashboard for unexpected API calls
- Restrict access — only share keys with team members who need them
Frequently Asked Questions About Kimi API
How do I authenticate with Kimi API?
Kimi API uses bearer token authentication. Include your API key in the Authorization header as 'Bearer your-api-key' with every request. The API key is generated from your Moonshot platform dashboard at platform.moonshot.cn.
Can I use multiple Kimi API keys?
Yes. Moonshot's platform allows generating multiple API keys per account. This is useful for separating development, staging, and production environments, or for tracking usage across different applications.
What happens if my Kimi API key is compromised?
Immediately revoke the compromised key from your Moonshot dashboard and generate a new one. The old key will stop working instantly. Review your API usage logs for any unauthorized calls and rotate all keys that may have been exposed.
Is there a rate limit per API key?
Yes. Each Kimi API key has rate limits based on your account tier. Free accounts have lower limits (approximately 3 RPM), while paid accounts receive higher limits. Contact Moonshot AI for enterprise-grade rate limits.
Can I use the same API key for K2 and K2.5?
Yes. A single Kimi API key works with all available models including K2, K2.5, K2 Instruct, and thinking variants. The model is specified in each API request, not tied to the key.
Summary
Kimi API authentication is straightforward — generate a key, add it to your headers, and start making calls. For step-by-step key generation instructions, see our API Key Guide. For code examples using your key, visit Code Integration.