Get Started with the Uncensored API
Integrate our uncensored LLM into your application with a standard OpenAI-compatible API. Pay per token via crypto and get immediate access to a pure, open-weight model without content filters.
Base URLhttps://api.roleplayuncensored.com/v1
Install your preferred OpenAI SDK
Start by installing the official library for your programming language. The openai package works for both Python and Node.js environments, ensuring compatibility with our standard endpoints.
- Python:
pip install openai - Node.js:
npm install openai
This single dependency handles authentication and request formatting for you.
Set the base URL and API key
Configure your client to point at our hosted server instead of the default OpenAI region. You will need the API key generated from your dashboard and the specific base URL for our uncensored model.
Set the base_url to https://api.roleplayuncensored.com/v1 and provide your key in the api_key field. This ensures all requests route to our infrastructure without hitting other vendors.
Make your first chat completion
Send a standard chat.completions.create request using the model ID uncensored. This model answers without refusing lawful adult or controversial topics, making it ideal for roleplay applications.
Ensure your context window stays within the 100,000 token limit for both prompt and completion combined.
curl https://api.roleplayuncensored.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Set difficulty to hard."}]
}'
Handle streaming responses
Enable streaming by setting stream: true in your request parameters. This returns tokens as they are generated, which is critical for maintaining low latency in interactive chat interfaces.
The final chunk of the stream includes the total token usage for billing purposes. This allows you to track costs in real-time without waiting for the full response to finish.
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 JSON mode for structured data
Request structured output by setting response_format to {"type": "json_object"}. The model will format its reply as valid JSON, which simplifies parsing for your backend logic.
This feature is useful when you need consistent data structures for character profiles or game state updates. It works alongside other parameters like temperature and top_p to control creativity.
from openai import OpenAI
client = OpenAI(base_url="https://api.roleplayuncensored.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)
Check available models
Call the GET /v1/models endpoint to list the models available to your account. This returns the model ID uncensored along with its capabilities and context window details.
Our service offers a single, pure model, so you do not need to manage complex routing logic. You can rely on this endpoint to verify connectivity and model availability before sending heavy workloads.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.roleplayuncensored.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);Frequently asked questions
Why is my uncensored roleplay API request failing with a 401 error?
A 401 error indicates an invalid or missing API key. Ensure you have copied the key from your dashboard correctly and that it is associated with an active account. If you regenerated your key, make sure your client is using the latest version.
What happens if I run out of credit during a request?
If your prepaid credit is exhausted, you will receive a 402 error code. Errors and refusals do not consume credit, but successful token generation does. You can top up instantly with USDT or USDC to resume service without downtime.
How does the 100,000 token context window work?
The 100,000 token limit applies to the sum of input tokens (prompt) and output tokens (completion). You can send large context windows but must ensure the combined total does not exceed this hard limit. Max output per request is 16,000 tokens.
Get your API key now
Sign up, copy the key, update your base URL. That is the entire configuration process.