Base URL and Authentication
Our API is fully OpenAI-compatible, meaning you can use any standard SDK with minimal changes. The base URL for all requests is https://api.openrouterapi.top/v1. Authentication is handled via a Bearer token passed in the Authorization header. You can generate this key instantly by signing up with Google or an email address on our dashboard. Keep your key secure, as it provides direct access to your prepaid credit.
First Request
Test the endpoint with a simple curl command. Replace YOUR_API_KEY with your actual key. The model ID is set to uncensored to bypass standard content refusals. This request sends a prompt and waits for the full response.
curl https://api.openrouterapi.top/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 the key is invalid, you receive a 401 error. If your prepaid balance is exhausted, you receive a 402 error. These errors do not consume your token balance, but they do count toward your rate limit quota.
Python SDK Integration
Using the official openai Python package is straightforward. Initialize the client with your base URL and key. The SDK handles the JSON serialization automatically. This example demonstrates a basic chat completion request.
from openai import OpenAI
client = OpenAI(base_url="https://api.openrouterapi.top/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)
Ensure you have installed the latest version of the SDK. The client object manages the connection pool, so you can reuse it for multiple requests without re-initializing.
Node SDK Integration
For JavaScript environments, the Node SDK works identically. Pass the custom base URL during initialization. This approach allows you to integrate uncensored generation into existing web apps or backend services seamlessly.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.openrouterapi.top/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);
The Node SDK supports both promise-based and async/await patterns. Error handling is consistent with other OpenAI-compatible services.
Streaming Responses
Enable streaming by setting stream: true in your request. The API returns Server-Sent Events (SSE). Each chunk contains partial text. The final chunk includes the 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)
Prepaid credit is charged based on the actual tokens generated in the final output. Streaming does not change the pricing model; you pay for the tokens that are successfully delivered.
Rate Limits and Context Window
Each API key is limited to 300 requests per minute and 8 concurrent requests. The maximum request body size is 8 MB. The context window supports up to 100,000 tokens total (input plus output). There is no separate output cap per request; if max_tokens is unset, the response can run to the end of the window. Errors like 401 or 402 do not consume credit, but they do count toward your rate limit. Refusals for specific content types are also free.