vi ▾

OpenAI-Compatible API Documentation

Connect to the uncensored AI API in seconds using standard OpenAI SDKs. This quickstart covers authentication, your first request, and handling streaming responses.

Base URL and Authentication

Your API key authenticates every request. Use the base URL https://api.openroutermodelsuncensored.com/v1 and set the model to uncensored. This works with any OpenAI-compatible client by updating the base URL and API key. Example: In Python, initialize the client with your key and the correct base URL. Check your key on the dashboard if requests fail.

Quickstart: First Request

Send a simple text completion to test connectivity. The API returns a direct response without additional filtering layers. Use the curl command below to verify your setup works. Note: The model ID is strictly uncensored, not a vendor name. This confirms your key and base URL are correct.

curl https://api.openroutermodelsuncensored.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "fetch latest commit hash for repo"}]
  }'

Check the response object for the generated text. Errors like 401 indicate an invalid key. 402 means you need to add crypto credit. 429 signals you hit the rate limit.

Python SDK Integration

Use the official OpenAI Python library for easy integration. Set the base URL to our endpoint and the model to uncensored. Example: Initialize the client with your key and base URL. This approach works with any OpenAI-compatible client.

from openai import OpenAI

client = OpenAI(base_url="https://api.openroutermodelsuncensored.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)

The response object contains the generated text. Use this for text generation tasks. Note: The model ID is strictly uncensored, not a vendor name. This confirms your key and base URL are correct.

Node SDK Integration

The Node.js SDK works identically to Python. Set the base URL to our endpoint and the model to uncensored. Example: Initialize the client with your key and base URL. This approach works with any OpenAI-compatible client.

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.openroutermodelsuncensored.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);

The response object contains the generated text. Use this for text generation tasks. Note: The model ID is strictly uncensored, not a vendor name. This confirms your key and base URL are correct.

Streaming Responses

Enable streaming by setting stream: true in your request. The API returns chunks as they are generated. Example: Use the SDK's stream method to handle chunks. This reduces perceived latency for long outputs.

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)

Process each chunk to build the final response. Note: Token usage is reported in the last chunk. Track usage to stay within your prepaid credit limits.

Limits, Errors, and Context

Your key allows 300 requests per minute and 8 concurrent requests. Example: Handle 429 errors by implementing exponential backoff. Retry after a short delay to avoid further throttling.

The context window is 100,000 tokens for prompt and completion combined. Example: Split long documents into chunks if needed. Max output is 16,000 tokens per request.

Error 401 means an invalid key. Error 402 means no credit. Example: Top up via crypto to resolve 402 errors. Credit never expires.

Frequently asked questions

What is the uncensored AI API base URL?

The base URL is HTTPS://api.openroutermodelsuncensored.com/v1. Use the model ID <code>uncensored</code> for all requests. This works with any OpenAI-compatible SDK.

How do I handle streaming responses?

Set <code>stream: true</code> in your request. The API returns chunks as they are generated. Process each chunk to build the final response. Token usage is in the last chunk.

What are the rate limits?

You get 300 requests per minute and 8 concurrent requests per key. Handle 429 errors by implementing exponential backoff. Retry after a short delay.

Get your key via a form

Sign up, grab the key, update your base URL. That is all.

Get API key