Quickstart: Drop-in OpenAI Compatible API
Drop-in OpenAI compatibility means you change one base URL and one key, then your existing code runs against our uncensored model without rewriting logic. This quickstart gets you from zero to a streaming response in minutes.
Change base_url and set API key
The first step is pointing your SDK at our endpoint. Use https://api.whatisopenrouterai.com/v1 as your base URL and paste your key from the dashboard. This single change redirects all calls to our uncensored large language model while keeping your standard OpenAI-compatible headers intact.
- Generate a key via Google or email.
- Store it in your environment variables.
- Verify the key works with a simple request.
curl https://api.whatisopenrouterai.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Set variable x to five"}]
}'
Send requests to /v1/chat/completions
Our API accepts standard chat completions with text input and returns text output. You send a POST request to the /v1/chat/completions endpoint with your model ID and message history. The model ID is simply uncensored, which tunes the model to answer without refusals for lawful adult content.
from openai import OpenAI
client = OpenAI(base_url="https://api.whatisopenrouterai.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)
Stream tokens with SSE
Streaming provides real-time feedback via Server-Sent Events. Each chunk contains partial text, and the final chunk includes the token usage statistics. This approach keeps your user interface responsive while waiting for long-form responses to complete.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.whatisopenrouterai.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);
Force json_object with response_format
Use the response_format parameter set to {"type": "json_object"} to enforce strict JSON output. This ensures predictable parsing for your applications without relying on the model to guess the correct structure every time.
Use tools and tool_choice
Function calling works exactly like the standard OpenAI API. Define your tools in the request, and the model will return structured arguments when appropriate. You can force tool usage with tool_choice or let the model decide based on the context.
Check available models
Query GET /v1/models to see the single uncensored model available. This endpoint returns the model ID and details, confirming that our service is active and ready to receive requests. We do not offer multiple model choices, keeping the integration simple and focused.
Streaming
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)Frequently asked questions
what is open router AI
It is a hosted, OpenAI-compatible API serving one uncensored large language model. You get a drop-in replacement for standard OpenAI code by changing the base URL and key. The model does not refuse lawful adult content, providing a true uncensored LLM experience.
How do I handle rate limits and errors?
You receive a 401 error for an invalid key, 402 if you have no credit, and 429 for rate limits. Our limit is 300 requests per minute per key. Errors and refusals do not consume your prepaid tokens.
What is the context window size?
The context window is 100,000 tokens for both prompt and completion. The maximum output per request is 16,000 tokens, or 2,048 if you do not specify max_tokens. This allows for substantial conversations without immediate truncation.