Base URL and Authentication
Connect to the API using the provided base URL and a prepaid token key. You authenticate by passing your API key in the request header, ensuring only your account accesses your credits. Sign up via Google or email to receive your key immediately without phone verification.
curl https://api.kimicodeapi.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "What is the current rate limit for free tier users?"}]
}'Your requests target the standard OpenAI-compatible endpoint. This design allows you to swap in our service without rewriting your existing client code, provided you update the base URL and credentials.
Chat Completions Endpoint
Send messages to the model using the POST /v1/chat/completions endpoint. You must specify the model ID as uncensored to access the optimized large language model running on our servers. The system accepts standard message roles like user or assistant for multi-turn conversations.
from openai import OpenAI
client = OpenAI(base_url="https://api.kimicodeapi.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)This endpoint handles text input and returns generated text. It does not support embeddings, images, or audio. Focus on your prompt structure to get the best results from the uncensored model.
Streaming Responses (SSE)
Enable real-time token delivery by setting the stream parameter to true in your request. The API returns Server-Sent Events (SSE) chunks, allowing your application to display text as it generates. The final chunk contains the complete token usage statistics for billing.
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)Streaming reduces perceived latency for end-users. You can process each token as it arrives, which is ideal for chat interfaces. Remember that streaming does not change the underlying model behavior or token pricing.
Function Calling and Tools
Define tools in your request to let the model output structured function calls. The API supports tool_choice parameters, allowing you to force the model to use a specific tool or decide autonomously. This feature works with standard OpenAI tool formats, making integration straightforward.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.kimicodeapi.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);Use function calling to extract data or trigger actions in your applications. The model interprets the tool definitions and returns JSON objects containing the necessary arguments. This capability extends the API beyond simple text generation.
JSON Mode and Parameters
Enforce strict JSON output by setting response_format to {"type": "json_object"}. This ensures the model returns valid JSON, which is crucial for programmatic parsing. You can also adjust parameters like temperature, top_p, and stop sequences to control creativity and output length.
The model supports a 100,000 token context window. This allows you to pass large amounts of context in a single request. Max output is 16,000 tokens per request, or 2,048 if you do not specify max_tokens.
Limits, Errors, and Context
Monitor your request limits to avoid service interruptions. The API allows 300 requests per minute per key and up to 8 concurrent requests. Your request body must stay under 8 MB. If you exceed these limits, you receive a 429 rate limit error.
Authentication failures return a 401 error if the key is invalid. A 402 error indicates insufficient prepaid credit. Errors during generation do not consume your tokens. The context window includes both prompt and completion tokens. Unused credit never expires, ensuring your prepaid balance remains available for future projects.