Base URL and Authentication
To begin using the uncensored API, point your client at our dedicated endpoint. The base URL is https://api.openrouteruncensored.cc/v1. This ensures your requests bypass standard OpenRouter routing and hit our direct infrastructure for the uncensored model.
Authentication is handled via a standard Bearer token. You obtain an api key by signing up with Google or email on our dashboard. Once generated, include it in your HTTP headers as Authorization: Bearer YOUR_API_KEY. This key is unique to your account; creating a new key revokes the previous one, so keep your active key secure.
First Request
Send your first text generation request using the standard POST /v1/chat/completions endpoint. You must specify the model ID as "uncensored". This tells the server which open-weight model to serve. The request body includes your system prompt, user messages, and optional generation parameters.
Below is a minimal curl example demonstrating the structure. Ensure your key has sufficient prepaid credit, as billing is pay-per-token.
curl https://api.openrouteruncensored.cc/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."}]
}'If you receive a 401 error, your key is invalid or expired. A 402 error means your prepaid balance is exhausted. Top up by crypto (USDT on TRC20, USDC on Base) to continue.
Python SDK
Use the official OpenAI Python library to integrate quickly. Set the base_url and api_key to match our infrastructure. This allows you to reuse existing codebases that were built for OpenAI without rewriting the client logic.
Initialize the client with your credentials and the correct base URL. Then call chat.completions.create with the model "uncensored". This approach works for both synchronous and asynchronous workflows, keeping your integration lightweight.
from openai import OpenAI
client = OpenAI(base_url="https://api.openrouteruncensored.cc/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)The response contains the generated text, token usage statistics, and the finish reason. Handle errors gracefully, especially network timeouts or rate limit responses.
Node SDK
For JavaScript or TypeScript environments, the OpenAI Node SDK provides a similar interface. Configure the client with our base URL and your API key. This ensures all subsequent calls route correctly to our uncensored model.
Instantiate the client, then invoke the chat completion method. Specify model: "uncensored" in the parameters. This method supports standard JSON payloads and returns structured data including content and usage metrics.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.openrouteruncensored.cc/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);This setup is ideal for server-side applications or edge functions where you need to generate text without managing HTTP connections manually. The SDK handles retries and serialization automatically.
Streaming Responses
Enable streaming by setting stream: true in your request. The server sends a series of Server-Sent Events (SSE) chunks. Each chunk contains a partial delta of the generated text. This allows you to display output in real-time to the user.
Parse the SSE stream in your client. The final chunk includes the total token usage for the request, which is critical for accurate billing tracking. Streaming reduces perceived latency significantly for long responses.
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)Ensure your client handles incomplete JSON or text gracefully, as streaming breaks the response into discrete events. Monitor the finish_reason in the last chunk to know when generation is complete.
Limits, Errors, and Context
Our API enforces strict rate limits to ensure stability. You are allowed 300 requests per minute and up to 8 concurrent requests per key. The maximum request body size is 8 MB. Exceeding these limits results in a 429 Too Many Requests error.
The context window is 100,000 tokens total (prompt + completion). There is no separate output cap; if you do not set max_tokens, the response can run to the end of the window. Errors and refusals do not consume your prepaid credit. If you encounter a 401, verify your key. For 402, top up by crypto (USDT on TRC20, USDC on Base).