API Documentation
Get started with the uncensored AI API in minutes. Send a simple text request and receive raw, unfiltered responses via the standard OpenAI-compatible endpoint.
Authentication and Base URL
The API requires a single API key for authentication. You receive this key immediately after signing up with Google or an email address. Pass it in the Authorization header as a Bearer token. The base URL is https://api.topuncensored.com/v1. This URL works with any OpenAI-compatible SDK or client library.
- Use the header:
Authorization: Bearer YOUR_API_KEY - Set your client's base URL to the provided endpoint.
This setup ensures you can swap libraries without changing your core logic.
curl https://api.topuncensored.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Generate a list of ten distinct UI layout patterns."}]
}'
Chat Completions Endpoint
Send text prompts to the /v1/chat/completions endpoint. The model ID is uncensored. This endpoint handles standard chat formatting with messages. It returns text responses directly. There are no extra layers or wrappers. You control the context window of 100,000 tokens. Requests under 8 MB work reliably. Use this for direct text generation.
Structure your request with a system prompt and user message. The model responds without filtering lawful adult content. Errors like missing keys return 401. Run out of credit? You get a 402 error. These are clear signals.
Streaming Responses
Enable streaming by setting stream: true. You receive chunks of text as they generate. This reduces perceived latency for long outputs. The final chunk includes token usage data. Use this for real-time displays or progressive rendering. It is efficient for high-volume applications.
Parse each chunk to build your final response. This method handles large outputs gracefully. The API supports standard Server-Sent Events. This is the recommended approach for interactive apps.
from openai import OpenAI
client = OpenAI(base_url="https://api.topuncensored.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)
Tool Calling and JSON Mode
Use function calling for structured interactions. Define tools in your request. The model returns structured arguments. Set response_format to {"type": "json_object"} for strict JSON output. This ensures predictable data formats. Combine these features for robust integrations. You get precise control over the output structure.
Tool calling works with the standard OpenAI schema. JSON mode forces valid JSON. Use these for API integrations or data extraction. This flexibility supports complex workflows.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.topuncensored.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);
Parameters and Limits
Adjust temperature, top_p, and stop sequences. Set max_tokens to 16,000. Default is 2,048 if omitted. Control repetition with presence_penalty and frequency_penalty. Use seed for deterministic outputs. These parameters fine-tune generation quality. You have full control over the output style.
Rate limits are 300 requests per minute. Concurrent requests cap at 8. These limits ensure stable performance. Monitor your usage via the dashboard. Adjust parameters to optimize for your specific use case.
Errors and Context Window
Handle errors gracefully. 401 means invalid key. 402 indicates insufficient credit. 429 signals rate limits. The context window is 100,000 tokens total. Output maxes at 16,000 tokens. Manage your tokens wisely. Errors do not consume credit. This saves money during debugging. Use the last chunk for usage stats.
Track your token usage. Avoid hitting rate limits. Retry with exponential backoff. This ensures reliable operation. The API is designed for robustness. Handle errors as part of normal flow.
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
Is the top uncensored API free?
No, it is pay-as-you-go. You get $0.50 trial credit for new accounts. Credit never expires. Errors are free. Crypto only for top-ups.
Can I use this with OpenAI SDKs?
Yes, it is fully OpenAI-compatible. Change the base URL and API key. It works with standard libraries. No custom code needed. This simplifies integration significantly.
What is the context window size?
The context window is 100,000 tokens. This includes prompt and completion. Max output is 16,000 tokens. This allows long conversations. Use it for detailed analysis.
Retrieve your API key
Sign up, grab your key, update the base URL. Done.