Install your SDK
Start by installing the official library for your language. We support the standard OpenAI SDK packages used by most developers. Install the package via your terminal to get ready for the next steps.
Configure base URL and key
Point your client to our endpoint and set your credentials. Use https://api.openrouterlimits.com/v1 as your base URL. Replace YOUR_API_KEY with the key you generated on the Get API key page. This setup works with any OpenAI-compatible client by changing the base_url and the API key.
Send your first completion
Make a request to generate text. Use the model ID uncensored to access our tuned open-weight model. The model does not refuse lawful adult or controversial topics. Send a POST request to /v1/chat/completions with your messages.
curl https://api.openrouterlimits.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Process 5000 records in under 2 seconds"}]
}'
Handle streaming responses
Enable streaming to receive tokens in real-time. Set stream to true in your request body. You will receive Server-Sent Events (SSE) containing partial text. The final chunk includes the token usage 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)
Use tools and JSON mode
Integrate function calling or strict JSON outputs. Use the tools parameter for function calling. Set response_format to {"type": "json_object"} for JSON mode. Supported parameters include temperature, top_p, stop, seed, presence_penalty, and frequency_penalty.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.openrouterlimits.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);
Monitor token usage
Track your usage and handle errors gracefully. You get 300 requests per minute and 8 concurrent requests per key. The context window is 100,000 tokens. Handle errors like 401 (invalid key), 402 (no credit), and 429 (rate limit). Errors and refusals are free. Credit never expires.
from openai import OpenAI
client = OpenAI(base_url="https://api.openrouterlimits.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)