How to Get a Kimi API Key: Create, Store and Rotate It

A Kimi API key is a server credential, not a login shortcut. Create it in the official Kimi Open Platform console, store it as a secret, give each environment or team member an appropriate key, and revoke it immediately if exposure is possible.

Console labels, project controls, endpoints, and security features can change. Use the official developer documentation and the controls displayed in your own project as the operational source of truth.

This page owns the credential lifecycle: choose the right credential, create it, store it, verify authentication, rotate it, and revoke it. To send a first chat request, continue to the Kimi API Quickstart.

First, Choose the Right Credential

Several Kimi-related access routes can look similar but are not interchangeable. Creating the wrong key leads to failed authentication, unexpected billing, or a tool that cannot use the credential.

Credential or accountCreated atUse it for
Kimi Open Platform API keyplatform.kimi.aiServer applications, scripts, agents, automation, and direct requests to the Kimi API
Kimi Code credentialThe official Kimi Code route shown by the productSupported coding tools and Kimi Code workflows
Kimi consumer accountKimi web or mobile appUsing Chat and membership features as an end user; it is not a general developer key
Third-party provider keyThe selected providerCalling that provider’s deployment and accepting its billing, model list, limits, and privacy terms

This guide covers the international Kimi Open Platform route, whose official API base URL is https://api.moonshot.ai/v1. A key issued by another regional or third-party platform must be used with that platform’s documented endpoint.

The API Key Lifecycle

  1. Plan: decide who owns the account, project, charges, and recovery process.
  2. Create: issue a key for one person, service, or environment—not for the entire company.
  3. Store: place the complete value in an environment variable or secret manager before closing the creation dialog.
  4. Assign: provide the minimum systems and people that need the secret.
  5. Monitor: review usage, spend, failed authentication, and unexpected sources.
  6. Rotate: replace the key on a schedule and whenever ownership or exposure changes.
  7. Revoke: disable the old or compromised key after the replacement is working.

Create a Kimi API Key in the Official Console

  1. Open the official API Keys console and sign in to the developer account that should own the usage charges.
  2. Select the intended organization and project. A small test can use the default project, but production systems should have an intentional project boundary.
  3. Choose the option to create a new API key.
  4. Use a purpose-based label when the interface allows it, such as staging-wordpress-backend or developer-alex-local. Do not put a password, customer name, or confidential project detail in the label.
  5. Create the key and copy the complete value immediately.
  6. Store it in an approved password manager, secret manager, or deployment secret before closing the dialog.
  7. Record the owner, project, environment, creation date, and planned rotation date without recording the key itself in the inventory.
Official Kimi API documentation explaining how to create and store an API key
Official Kimi API instructions for creating an API key. No personal API key is displayed. Screenshot captured September 8, 2026.

Store the Key Before You Test It

Kimi’s official API documentation warns against exposing keys in client-side code, public repositories, or logs and recommends environment variables. The examples below set the variable for a local session; production deployments should use the host’s encrypted secret system.

macOS or Linux

export MOONSHOT_API_KEY="paste-the-key-here"

For a persistent setup, use your shell’s secure configuration process or a secret manager. Do not commit the value to a dotfile repository.

Windows PowerShell

$env:MOONSHOT_API_KEY="paste-the-key-here"

This sets the variable for the current PowerShell session. Use Windows or your deployment platform’s secret-management feature for persistent production storage.

Local .env file

MOONSHOT_API_KEY=paste-the-key-here

Add the file to .gitignore before the first commit:

.env
.env.*
!.env.example

An example file may contain MOONSHOT_API_KEY= with an empty value, but never a real secret.

Verify Authentication Without Sending a Full Model Request

Use the official List Models endpoint as a narrow credential check. A successful response confirms that the server accepted the Bearer token and returns the models currently visible to the account. It does not test prompt quality or complete the application quickstart.

curl --request GET \
  --url https://api.moonshot.ai/v1/models \
  --header "Authorization: Bearer $MOONSHOT_API_KEY"

Expected interpretation:

  • A model list is returned: authentication worked and the account can see its current inventory.
  • HTTP 401: check the copied value, environment variable, endpoint, project status, and whether the key was revoked. Do not print the full key while debugging.
  • Another error: record the HTTP status, official request identifier if present, and sanitized message; then use the Kimi API errors guide.

Once authentication is confirmed, use the API Quickstart for the first chat completion and the Kimi API models guide for workload selection.

Separate Development, Staging, and Production

One key for every system makes incidents harder to contain. Split environments so that a local experiment cannot consume the production budget and a leaked staging secret can be revoked without taking the live service offline.

EnvironmentRecommended boundaryKey ownerTypical control
DevelopmentDedicated project or tightly limited development scopeIndividual developer or development serviceSmall budget, non-sensitive test data, frequent rotation
StagingSeparate project and deployment secretStaging service account or responsible operatorProduction-like tests without production data
ProductionProduction-only project and secret managerNamed service ownerAlerts, restricted access, documented rotation and rollback

For a team, prefer individual keys or service-specific credentials rather than sending one shared value through email or chat. Removal of a member, vendor, or application should have a matching key-revocation step.

WordPress and Browser Apps: Keep the Key Behind a Backend

A secret embedded in JavaScript, a mobile bundle, a public repository, a page source, or a WordPress shortcode output is not secret. The safe request path is:

  • Browser: sends the user’s request to your own authenticated WordPress REST endpoint.
  • WordPress backend: validates nonce or session, rate-limits the user, checks payload size, and retrieves the API key from a server-side secret.
  • Kimi API: receives the server-to-server request.
  • Backend: filters the response, records minimal operational metrics, and returns only the needed result to the browser.

Do not expose the key through wp_localize_script(), HTML data attributes, front-end environment variables, downloadable configuration files, or client-side fetch calls. Add per-user limits, global budget controls, timeout handling, and abuse protection before making a public tool available.

Rotate a Key Without Downtime

  1. Create a replacement key in the same intended project and record its new rotation date.
  2. Add the replacement to the secret manager without deleting the old value yet.
  3. Deploy the new secret to one test or canary instance.
  4. Run the authentication check and one normal application health check.
  5. Roll out to all instances and confirm that requests use the replacement.
  6. Revoke the old key in the official console.
  7. Monitor for failures from forgotten jobs, old servers, developer machines, and scheduled tasks.

If the Key May Have Been Exposed

Treat suspected exposure as real. Do not wait for proof of misuse and do not merely remove the key from the latest Git commit; copies may remain in history, logs, caches, build artifacts, screenshots, and messages.

  • Revoke the affected key immediately.
  • Create and deploy a replacement through the rotation process.
  • Review usage and billing around the earliest possible exposure time.
  • Search repositories, history, CI logs, support tickets, analytics, and chat systems for the leaked value or recognizable prefix.
  • Remove the secret from history and artifacts using the appropriate repository and deployment procedures.
  • Record the root cause and add a preventive control such as secret scanning, log redaction, or a blocked client-side build variable.
  • Contact official platform support when unauthorized usage or billing is suspected.

Where to Go After the Key Is Safe

Next jobUse this page
Send the first authenticated chat requestKimi API Quickstart
Choose a model by workload and acceptance testKimi API Models
Estimate token and request costKimi API Pricing
Use an OpenAI-format client or frameworkKimi OpenAI-Compatible API
Diagnose a status code or error payloadKimi API Errors

Frequently Asked Questions

Is a Kimi API key included in my personal Kimi membership?

Do not treat personal membership and Open Platform API billing as the same product. Create and fund the appropriate developer account for programmatic requests.

Can I put the Kimi API key in browser JavaScript?

No. A browser user can inspect the bundle, network activity, page source, and runtime values. Proxy requests through a controlled backend and keep the key in server-side secret storage.

Should a whole team share one API key?

Prefer individual or service-specific keys within managed projects. This improves attribution, rotation, offboarding, incident containment, and cost investigation.

How do I know whether the key works?

Call the official GET /v1/models endpoint with Bearer authentication. A successful model-list response verifies authentication. Then use the Quickstart for a full request.

How often should I rotate the key?

Use an organization-defined schedule and rotate immediately after suspected exposure, personnel changes, vendor offboarding, project transfer, or a security-policy trigger. The correct interval depends on your risk and deployment controls.

Why does my third-party Kimi key fail on the Moonshot endpoint?

Keys are tied to the issuing platform. A third-party or regional key must use that provider’s endpoint, model identifiers, billing, and documentation unless the provider explicitly states otherwise.

Official Sources and Verification

Last verified: August 31, 2026.


Mohamed Hossam El-Din
Mohamed Hossam El-Din

Mohamed Hossam El-Din is a content editor at Thinkly for Digital Business, responsible for kimi-ai.free. He is a social work student at Helwan University, and he came to Kimi the way most of its users do: with long PDFs to read, research to gather, and reports to write. That is the angle he writes from — long-context work, document analysis, and research, tested on a live account before it is written about. He writes in English and Arabic. Every feature covered here was used first; error messages published on this site are errors that actually appeared. When a claim cannot be verified against Moonshot AI's official documentation, the article says so.

Articles: 49