EN ▾
Get API key

Quickstart: Integrate the Uncensored API

Integrate the uncensored LLM API into your stack with a single base URL change and zero subscription lock-in. This guide covers authentication, streaming, and tool usage for the AiNoCensor endpoint.

Authentication: Setting the API Key

Obtain your key via Google or email login on the Get API key page and pass it in the Authorization header. The system issues one active key per account, replacing any previous key immediately. This simple setup ensures you can start sending requests without configuring complex proxy chains or managing monthly billing cycles.

curl https://api.ainocensor.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "List the top five Rust crates for async networking."}]
  }'

Keep your key secure. The platform does not track or log prompts for training, so your data remains yours while you build unrestricted applications.

Basic Request: Chat Completions

Send a POST request to https://api.ainocensor.com/v1/chat/completions using the model ID uncensored to receive text responses. This endpoint supports standard parameters like temperature and top_p for controlling randomness. You do not need to switch SDKs; any OpenAI-compatible client works by adjusting the base URL.

from openai import OpenAI

client = OpenAI(base_url="https://api.ainocensor.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 model answers without content refusals for lawful adult or creative topics, making it ideal for NSFW chatbot implementations or deep context retention tasks.

Streaming Responses (SSE)

Enable streaming by setting stream: true to receive tokens via Server-Sent Events (SSE) for lower latency. This approach is crucial for real-time UI updates where waiting for a full response would cause noticeable delays. The final chunk contains the total token usage for billing transparency.

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)

Errors and refusals do not consume credit, so streaming large outputs remains cost-effective even if the connection drops unexpectedly.

Function Calling & Tools

Define your tools in the request body and use tool_choice to let the model decide when to invoke them. This capability allows the uncensored LLM to integrate with external systems without manual parsing of text outputs. You can specify required or auto modes depending on your application's needs.

import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.ainocensor.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 API supports standard tool definitions, ensuring compatibility with existing agent frameworks that expect OpenAI-style function calling structures.

JSON Mode Configuration

Set response_format to {"type": "json_object"} to force the model to output strictly valid JSON. This feature is essential for parsing structured data in automated pipelines or building reliable NSFW story generators that require specific schema adherence. It eliminates the need for regex cleanup on malformed outputs.

The model is tuned to maintain this format even under high creativity settings, ensuring your parser receives consistent data structures.

Handling Errors and Limits

Monitor for 401 errors if your key is invalid, 402 errors when prepaid credit is exhausted, and 429 rate limits triggered by exceeding 300 requests per minute. The API enforces a 8 MB request body limit and allows up to 8 concurrent requests per key. Your prepaid credit never expires, so you can pause usage between projects without losing your balance.

With a 100,000 token context window, you can feed extensive documents or conversation histories into the uncensored model without losing earlier context.

Common questions

How does the uncensored model handle controversial topics?

The model is tuned to answer without content refusals for lawful adult, fictional, or controversial topics. It does not apply standard safety filters, allowing for unrestricted creative or NSFW use cases while still refusing sexual content involving minors.

What happens if I hit the rate limit?

You will receive a 429 status code. The limit is 300 requests per minute per key and 8 concurrent requests. You can generate a new key to replace the old one if needed, though each account is limited to one active key at a time.

Is the credit refundable if I make a mistake?

No, prepaid credit is not refundable, but it never expires. If you experience a double charge or other billing error, you can resolve it through the Support page without losing your existing balance.

Retrieve your API key

Register, copy the key, update the endpoint URL. Complete integration in seconds.