API Documentation
Integrate the open router AI API into your existing stack by updating your base URL and API key. This drop-in compatibility lets you generate unrestricted text using standard OpenAI protocols without rewriting your application logic.
Base URL and Authentication
The API endpoint lives at https://api.openrouteraiapi.com/v1. Pass your API key in the Authorization header as a bearer token. This header is the only change needed to redirect traffic from your current provider to our uncensored model.
Authentication is strict. If the key is missing or invalid, the server returns a 401 error immediately. You can generate a key instantly via Google or email on the dashboard. Keep the key secure, as it grants access to your prepaid credit.
Chat Completions Endpoint
Send POST requests to /v1/chat/completions with a messages array. The model identifier is uncensored. This single model handles all your text generation needs without complex routing logic.
Here is a standard request using cURL to verify connectivity and response format.
curl https://api.openrouteraiapi.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "list the top five python libraries for data science"}]
}'The response includes the generated text in the choices[0].message.content field. You can parse this directly into your application workflow.
Python SDK Integration
Use the official OpenAI Python client to connect effortlessly. Set the base_url and api_key variables to point to our infrastructure. This approach minimizes code changes when switching providers.
from openai import OpenAI
client = OpenAI(base_url="https://api.openrouteraiapi.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)The client handles serialization and retries automatically. You receive a completion object containing the text and token usage statistics. This method is ideal for backend services and scripts.
Node.js SDK Usage
Initialize the OpenAI Node.js client with your custom base URL. This allows JavaScript applications to interact with the uncensored model using familiar methods. The SDK manages the HTTP requests efficiently.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.openrouteraiapi.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);Call chat.completions.create() with your messages. The response object provides access to the generated content and usage data. This integration works well for web servers and edge functions.
Streaming Responses
Enable streaming by setting stream: true in your request. The server returns Server-Sent Events (SSE) for real-time token delivery. This feature reduces perceived latency for end-users.
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)Each chunk contains partial content. The final chunk includes the complete token usage statistics. Handle these events in your client to update the UI incrementally.
Limits, Errors, and Context Window
The context window supports 100,000 tokens for input and output combined. Each request can output up to 16,000 tokens, or 2,048 if max_tokens is unset. Rate limits allow 300 requests per minute per key.
Errors are standard HTTP codes. A 401 indicates an invalid key. A 402 means your prepaid credit is exhausted. A 429 signals that you have exceeded the rate limit. Requests that fail do not consume credit. Errors are free.
Questions and answers
How does the open router AI API handle authentication failures?
The API returns a 401 Unauthorized status code if the header is missing or the key is invalid. This happens immediately upon request. Check your dashboard to ensure the key is active and correct.
What happens if I exceed the rate limit?
You receive a 429 Too Many Requests error. The limit is 300 requests per minute per key. You can monitor your usage via the dashboard. Upgrade your credit or wait for the window to reset.
Is the uncensored model limited by a 100,000 token context window?
Yes, the total context window is 100,000 tokens for both prompt and completion. You can generate up to 16,000 tokens per request. This allows for extensive document processing without cutting off mid-thought.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.