EN ▾
Get API key

kimiapikey.comDocs

Kimi API: First request in five minutes

Get your first response in under five minutes using the standard OpenAI-compatible interface. This guide covers setup, authentication, and basic usage for the uncensored model.

Get API key

Prerequisites

To start, you need an API key from kimiapikey.com. Sign up with just an email and password; no credit card is required for the trial. You also need a supported language environment with an official or compatible SDK installed. Our API follows the OpenAI chat-completions format, so existing code for GPT-3.5/4 often works with minimal changes. Ensure your SDK version is recent enough to support the base_url parameter.

Base URL and Authentication

Our API lives at https://api.kimiapikey.com/v1. Authentication is handled via the standard Authorization header. Pass your key as a Bearer token. This works with any client that accepts OpenAI-compatible endpoints. If you are using a proxy or custom client, ensure it forwards the Authorization header correctly. The model ID you will request is uncensored.

First Request

Send a simple chat completion to verify your setup. Use the curl command below, replacing YOUR_API_KEY with your actual key. This request sends a short prompt to the uncensored model. If successful, you will receive a JSON response containing the model's reply. Check the choices array for the generated text. If you get a 401 error, your key is invalid or expired.

Python SDK

Use the official OpenAI Python library for the easiest integration. Set the base_url to our endpoint and provide your key. This example demonstrates a basic text generation call. You can adjust the model parameter if needed, though uncensored is the default. This approach keeps your code portable across different OpenAI-compatible services.

Node SDK

For JavaScript/TypeScript projects, use the openai npm package. Configure the client with our base URL and your API key. This allows you to make requests directly from your Node environment. The syntax mirrors the Python SDK, ensuring consistency if you switch languages. Remember to handle asynchronous responses correctly using await.

Streaming Responses

For real-time output, enable streaming in your SDK. This sends chunks of text as they are generated, reducing perceived latency. Use the stream flag in your request. The SDK will yield partial responses, allowing you to update the UI incrementally. This is ideal for chat interfaces or long-form content generation where immediate feedback is valuable.

Limits and Errors

Each key is limited to 300 requests per minute. If you exceed this, you will receive a 429 error. Your request body must not exceed 8 MB. A context window of 100,000 tokens applies to the sum of prompt and completion. Common errors include 401 (invalid key) and 402 (insufficient credit). Top up via the dashboard to continue using the API. Credits never expire, and there are no monthly fees.

cURL

curl https://api.kimiapikey.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
  }'

Python

from openai import OpenAI

client = OpenAI(base_url="https://api.kimiapikey.com/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)

Node.js

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.kimiapikey.com/v1", apiKey: process.env.API_KEY });

const resp = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);

Streaming

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Tell the story in second person."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Questions and answers

Does the API support function calling?

Yes, the endpoint supports tool/function calling in the standard OpenAI format. You can define tools in your request and the model will return structured arguments.

What happens if I exceed the rate limit?

You will receive a 429 Too Many Requests error. Wait briefly and retry, or upgrade your prepaid credit tier to maintain higher throughput.

Is the model trained on my data?

No. Prompts sent to the API are not used for training. Your data remains private and is not used to improve the base model.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API keyRead the docs

API facts in one table

Everything the endpoint can and cannot do, in one place — check it before you top up.

FeatureSupport
ProtocolOpenAI Chat Completions schema; official openai SDKs work unchanged
Modeluncensored
AuthenticationBearer token in the Authorization header
EndpointsPOST /v1/chat/completions · GET /v1/models
Base URLhttps://api.kimiapikey.com/v1
Completion lengthup to the rest of the 100,000-token window; max_tokens optional (no separate cap)
Other parameterstemperature, top_p, stop, seed and the two penalties are passed through
Function callingSupported: tools + tool_choice, tool_calls in the reply (streamed too), tool results as role: tool messages
StreamingSupported (stream: true), usage included at the end
Context window100,000 tokens, input and output combined
JSON moderesponse_format: {"type": "json_object"}
Parallel requests8 requests at the same time per key
Rate limit300/min per key
HeadersX-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency
Request sizeup to 8 MB per request
Price$0.15 per 1M input tokens · $0.50 per 1M output tokens
Billingprepaid credit, charged by real token usage; errors and refusals are free
Volume bonus+5% from $50, +10% from $100, +15% from $200
Subscriptionno monthly fee; paid credit does not expire
Top-upcrypto: USDT on TRON or USDC on Base, $20–$500, any whole sum
Free trial$0.50 for 7 days, no card · Trial key: 2 parallel requests, 60 req/min; full limits (8 and 300) after first top-up
Keysone active key per account; a new key replaces the old one
Sign-insign in with Google or with e-mail + password
Contentadult content allowed; sexual content involving minors is refused

Error codes

The type field is stable, the message is for humans. Errors cost nothing.

CodeTypeMeaning
400bad_requestinvalid JSON, empty messages, bad parameter, or a prompt longer than the window — fix and resend
401missing_key · invalid_key · key_revokedcheck the Authorization header or use your current key
402no_creditbalance is empty — top up, requests resume at once
403content_blockedsexual content involving minors — refused, not billed
404not_foundunknown endpoint
413request_too_largerequest body larger than 8 MB
429rate_limited · concurrencyover 300/min or 8 parallel — back off and retry
503upstream_busymodel busy — retry in a few seconds