API Documentation - KimiCode
Start sending requests to our uncensored LLM API in seconds. The service is fully OpenAI compatible, so you just change the base URL and API key in your existing client code.
Base URL and Authentication
Connect your code to our API by updating the base URL and providing your key in the header. We support standard authentication, so existing OpenAI SDK clients work immediately without complex setup. Your API key appears instantly after signup via Google or email, with no phone number required.
Each account holds one active key at a time; generating a new key replaces the old one. Requests are authenticated via the Authorization header, ensuring secure access to your prepaid credit.
First Request
Send your first message using the standard chat completions endpoint with a simple POST request. This confirms your integration works before you dive into advanced features or streaming data. The response returns text output from the uncensored model.
- Replace YOUR_API_KEY with your key from the dashboard.
- Set the model to 'uncensored' for our specific open-weight model.
curl https://api.kimicodepricing.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "List available plan tiers and token costs"}]
}'
Python SDK Integration
Use the official OpenAI Python library to interact with our API by pointing it to our base URL. This approach leverages familiar syntax, allowing you to switch providers without rewriting your entire application logic. The library handles tokenization and request formatting automatically.
- Install the openai package via pip.
- Configure the base URL to point to our service.
from openai import OpenAI
client = OpenAI(base_url="https://api.kimicodepricing.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 SDK Integration
Integrate our API into your JavaScript or TypeScript applications using the Node SDK. This ensures consistent behavior across your frontend and backend environments. You can pass messages and receive responses just like you would with any standard OpenAI-compatible service.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.kimicodepricing.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 and Token Usage
Enable streaming to receive real-time token generation via Server-Sent Events (SSE). This reduces perceived latency for users and allows immediate display of partial results. Token usage data, including input and output counts, is embedded in the final chunk of the stream.
This method is ideal for chat interfaces where instant feedback matters. You can parse the stream to update the UI progressively without waiting for the entire response.
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)
Limits, Errors, and Context
Manage your usage by understanding rate limits and common error codes. The API supports a 100,000 token context window, allowing deep conversation history. You are limited to 300 requests per minute and 8 concurrent requests per key.
- 401 indicates an invalid or missing API key.
- 402 signals that your prepaid credit is exhausted.
- 429 means you have exceeded the rate limit.
Errors do not consume your credit, so you can retry failed requests without penalty.
FAQs
What is kimicode pricing per token?
We charge $0.15 per 1M input tokens and $0.50 per 1M output tokens. Errors and refusals do not consume credit, so you only pay for successful responses.
Does the API support streaming responses?
Yes, the API supports streaming via Server-Sent Events (SSE). Token usage details are included in the final chunk of the stream, allowing you to track costs in real time.
How do I handle rate limits?
You are limited to 300 requests per minute and 8 concurrent requests per key. Exceeding these limits returns a 429 error code, which does not deduct from your credit.