Integrate routerapi in Minutes
Drop your existing OpenAI-compatible code into routerapi with a single variable change. Get an uncensored endpoint running in minutes without retraining your integration logic.
Contents
Authentication and Base URL Setup
Change base_url and api_key to switch providers instantly. Point your SDK to HTTPS://api.routerapi.cc/v1 and use the key generated from your dashboard. No complex routing rules or multi-model configuration is required. Your existing headers and client setup remain identical to the OpenAI standard.
The key is displayed immediately after signup via Google or email. Store it securely and pass it as the Bearer token in your HTTP Authorization header. This single change routes all requests to our uncensored model without altering your application code.
Sending a Chat Completion Request
Send a standard POST request to /v1/chat/completions to generate text. The endpoint accepts the same JSON structure used by OpenAI, ensuring your prompts work without modification. Use the model ID uncensored to access our large language model tuned for unrestricted responses.
Each request consumes tokens from your prepaid balance. Errors and refusals do not charge your credit, so you can test freely. The following example demonstrates a basic text generation call using the official SDK.
curl https://api.routerapi.cc/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Summarize this 1000 word article in three sentences."}]
}'The response returns the generated text in the choices[0].message.content field. You can adjust parameters like temperature or top_p to control creativity. No embeddings or image generation endpoints are available; this service focuses strictly on text completion.
Handling Streaming Responses (SSE)
Enable streaming by setting stream: true in your request body. The API returns Server-Sent Events (SSE) for real-time token delivery. This reduces perceived latency for chat interfaces and roleplay applications. Each chunk contains a partial delta of the response.
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)The final chunk includes the complete token usage statistics for the request. Parse the content field from each delta to reconstruct the full message. This approach keeps your UI responsive while the model processes long contexts. Token counts in the final chunk reflect both input and output usage.
Using Tools and Function Calling
Pass tool definitions in the tools parameter to enable function calling. The model returns structured tool calls in the response instead of plain text. Specify tool_choice to force the model to use a specific function or auto-select. This feature works identically to the OpenAI function calling format.
from openai import OpenAI
client = OpenAI(base_url="https://api.routerapi.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)Define your functions with JSON schemas and pass them in the request. The API handles the routing between text generation and tool invocation. Use the response_format parameter with {"type": "json_object"} for strict JSON output when tools are not required. This ensures consistent structured data for your backend services.
Setting JSON Mode for Structured Output
Force the model to output valid JSON by setting response_format to {"type": "json_object"}. This is essential for parsing data in automated workflows or AI agents. The model will attempt to close all brackets and follow the requested schema. Errors may occur if the output becomes too long for the context window.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.routerapi.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);Combine JSON mode with temperature set to 0 for maximum determinism. Use this for extracting entities, formatting data, or generating configuration files. The uncensored model handles complex nested structures well. Always validate the output in your code before processing.
Understanding Token Limits and Costs
The context window supports 100,000 tokens for both prompt and completion combined. Each request can output up to 16,000 tokens, or 2,048 if max_tokens is unset. Pricing is $0.15 per million input tokens and $0.50 per million output tokens. Credit never expires and errors are free.
Monitor your usage via the dashboard or the response headers. Requests are limited to 8 MB in body size. You can top up with USDT (TRC20) or USDC (Base) starting at $20. Bonus credit increases with larger deposits: +5% at $50, +10% at $100, and +15% at $200. No subscription fees apply.
Frequently asked questions
How do I handle rate limits and errors?
The API enforces a limit of 300 requests per minute and 8 concurrent requests per key. A 429 status code indicates you have exceeded these limits; wait briefly before retrying. A 401 error means your API key is invalid, and a 402 error indicates insufficient prepaid credit. Check the error message body for details on which limit was triggered.
Is routerapi suitable for high-volume production use?
Yes, the service supports concurrent requests and streaming for low-latency applications. However, it lacks SLA guarantees and advanced features like embeddings. Use it for chat, roleplay, or creative writing where uncensored output is critical. Monitor your token usage to ensure your prepaid balance covers your volume.
What happens to my credit if I make a mistake?
Credit is prepaid and never expires, so unused funds remain available indefinitely. Mistakes like double charges are resolved via the Support page. Errors and refusals do not consume your credit, so testing your prompts is free. You can top up again at any time using crypto.
Get your API key
Sign up, grab your key, point to the new base URL. Done.