EN ▾
Uncensored LLM API for Developershttps://api.uncensoredai.top/v1
Get API key

Uncensored AI API Python Quick Start

You can reach an uncensored AI API from Python with the standard OpenAI library: change the base URL, pass your key, and set the model to the ID this service uses. Below are the exact steps, then streaming, multi-turn chat, JSON output and tool calls.

Updated:

Glowing ribbon flowing from a terminal into an open lock, picturing a Python call to an uncensored AI API
Key points
  • Install openai, point base_url at https://api.uncensoredai.top/v1 and pass the model ID from the first example.
  • No SDK is required: a plain requests.post to /v1/chat/completions works.
  • You keep the chat history yourself and send it with every call.
  • 429 means a limit was hit; read Retry-After and try again.

No card needed. After sign-up, claim $0.50 of free test credit with one click (once per person).

Get API key

Five steps to a working call

  1. Create an account with Google or with email and password, then open the API key page and create a key. New users can claim $0.50 of trial credit there with one click, no card needed, valid for 7 days.
  2. Store the key in an environment variable: export UNCENSORED_KEY="your-key".
  3. Install the library: pip install openai.
  4. Create a client with base_url set to https://api.uncensoredai.top/v1.
  5. Call chat.completions.create with the model ID uncensored.

That is the whole setup. The service is OpenAI-compatible, so code written for the OpenAI SDK needs two changed values and nothing else. If you want a longer step-by-step walkthrough for developers, see the integration guide.

Your first request

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.uncensoredai.top/v1",
    api_key=os.environ["UNCENSORED_KEY"],
)

resp = client.chat.completions.create(
    model="uncensored",
    messages=[
        {"role": "system", "content": "You are a blunt, concise editor."},
        {"role": "user", "content": "Rewrite: the thing was done by the team quickly."},
    ],
    temperature=0.7,
)

print(resp.choices[0].message.content)
print(resp.usage.prompt_tokens, resp.usage.completion_tokens)

The usage line prints the number of tokens in and out, which you can multiply by the prices on the pricing page ($0.15 per 1M input, $0.50 per 1M output) to see what the call cost. The model behind the endpoint is an open-weight model run by an independent provider and tuned to answer without content refusals for lawful adult use. It is not the official API of any big vendor, and it is a different thing from a router that picks between vendors, so expect one consistent model rather than a choice.

To list what the key can use, call client.models.list(), which maps to GET /v1/models.

Keeping keys and settings out of your code

A key pasted into a script ends up in a Git repository sooner or later. A small amount of structure avoids that and makes the project easier to move between machines.

Put the key and base URL in environment variables, and read them in one module that the rest of your code imports. A .env file loaded with the python-dotenv package works well in development; add it to .gitignore on the first day. In production, use whatever secret store your host provides.

# llm.py
import os
from openai import OpenAI

client = OpenAI(
    base_url=os.environ.get("UNCENSORED_BASE_URL", "https://api.uncensoredai.top/v1"),
    api_key=os.environ["UNCENSORED_KEY"],
)
MODEL = "uncensored"

Every other file then does from llm import client, MODEL. If you later add a second endpoint for tests, you change one line. The same pattern works for the async client: create AsyncOpenAI in the same module and import it where needed.

Treat a leaked key as lost. If it appears in a public place, create a new one on the key page and stop using the old one. Because credit is prepaid, the worst case is limited to your balance, which is one more reason to top up in modest amounts while you test.

No SDK: plain requests

If you do not want a dependency, the HTTP call is short. This is useful in scripts, serverless functions and anywhere the openai package is awkward to install.

import os
import requests

r = requests.post(
    "https://api.uncensoredai.top/v1/chat/completions",
    headers={"Authorization": "Bearer " + os.environ["UNCENSORED_KEY"]},
    json={
        "model": "uncensored",
        "messages": [{"role": "user", "content": "Name three uses for a haiku."}],
        "max_tokens": 200,
    },
    timeout=120,
)
r.raise_for_status()
print(r.json()["choices"][0]["message"]["content"])
print(r.headers.get("X-Request-Id"), r.headers.get("X-Balance-USD"))

The same call in curl, handy for a quick test from a terminal:

curl https://api.uncensoredai.top/v1/chat/completions   -H "Authorization: Bearer $UNCENSORED_KEY"   -H "Content-Type: application/json"   -d '{"model":"uncensored","messages":[{"role":"user","content":"Hello"}]}'

The response headers carry X-Request-Id and X-Balance-USD. Quote the first when you contact support, and use the second to track your remaining credit.

Chat history and streaming

The API is stateless. It remembers nothing between calls, so a conversation is a list you grow yourself. Append the user message, send the list, append the assistant reply, repeat. Combine that with streaming and you have a small terminal chat:

history = [{"role": "system", "content": "You are a witty co-writer."}]

while True:
    text = input("you: ")
    if text in ("quit", "exit"):
        break
    history.append({"role": "user", "content": text})

    stream = client.chat.completions.create(
        model="uncensored",
        messages=history,
        stream=True,
        temperature=0.9,
    )
    reply = ""
    print("ai: ", end="")
    for chunk in stream:
        if chunk.choices and chunk.choices[0].delta.content:
            piece = chunk.choices[0].delta.content
            reply += piece
            print(piece, end="", flush=True)
    print()
    history.append({"role": "assistant", "content": reply})

The context window is 100,000 tokens, prompt and completion together, which is a long conversation. Even so, the whole history is billed as input on every turn, so long chats cost more per message than short ones. A ten-turn chat that averages 2,000 tokens in and 300 tokens out per turn uses 20,000 input tokens ($0.003) and 3,000 output tokens ($0.0015), which is $0.0045 in total. Trim or summarize old turns if a session goes on for hundreds of messages.

A streamed request holds one of your concurrent slots until the stream ends, so close it or read it to the end.

JSON output and tool calls

Programs want structure. JSON mode makes the reply a valid JSON object:

import json

resp = client.chat.completions.create(
    model="uncensored",
    response_format={"type": "json_object"},
    messages=[
        {"role": "system", "content": 'Reply as JSON: {"name": str, "traits": [str]}'},
        {"role": "user", "content": "Invent a grumpy dwarf blacksmith for my story."},
    ],
)
character = json.loads(resp.choices[0].message.content)
print(character["name"], character["traits"])

Tool calling lets the model ask your code to do something, like look up a record. You describe functions in tools, the model answers with a tool_calls entry, you run the function, and you send the result back as a message with the role tool.

tools = [{
    "type": "function",
    "function": {
        "name": "roll_dice",
        "description": "Roll a die with the given number of sides",
        "parameters": {
            "type": "object",
            "properties": {"sides": {"type": "integer"}},
            "required": ["sides"],
        },
    },
}]

messages = [{"role": "user", "content": "Roll a twenty-sided die for me."}]
first = client.chat.completions.create(
    model="uncensored", messages=messages, tools=tools, tool_choice="auto"
)
msg = first.choices[0].message

if msg.tool_calls:
    call = msg.tool_calls[0]
    messages.append(msg)
    messages.append({"role": "tool", "tool_call_id": call.id, "content": "17"})
    final = client.chat.completions.create(
        model="uncensored", messages=messages, tools=tools
    )
    print(final.choices[0].message.content)

In real code you would parse call.function.arguments as JSON and run your function with it. The hard-coded "17" keeps the example short.

Sampling settings that matter

Most Python examples copy the defaults and move on, but a few parameters change results noticeably. The endpoint passes temperature, top_p, stop, seed and the frequency and presence penalties through to the model.

Temperature

Low values (0 to 0.3) make answers steady and are right for extraction, classification and anything you want to repeat. Values around 0.8 to 1.0 give livelier prose and suit fiction, dialogue and brainstorming. Past 1.2 the text tends to drift, so reach for it only when you have a reason.

Top_p and penalties

Change one of temperature and top_p, not both at once, or you will not know which one did what. The penalties help when the model repeats a phrase in long outputs. Raise them in small steps, because large values push the text toward odd word choices.

Seed and stop

Pass a fixed seed while you tune a prompt so you can compare two versions on the same random draw. Use stop to cut generation at a marker such as a blank line, which also trims the output tokens you pay for.

max_tokens

It is optional, and a completion can use whatever is left of the 100,000 token window. Set it anyway for anything automated. Output tokens cost $0.50 per 1M against $0.15 per 1M for input, so a runaway answer is the most expensive mistake a script can make.

When something goes wrong

SymptomLikely causeFix
401 or an authentication errorMissing or wrong key, or the Bearer prefix is absentPrint the first four characters of the variable you load; with requests, send the header Authorization: Bearer plus the key
404 on the requestBase URL missing /v1, or a typo in the pathUse https://api.uncensoredai.top/v1 as base_url and let the SDK add /chat/completions
429 with rate_limitedMore than 60 (trial) or 300 (full) requests per minuteSlow the loop and honor Retry-After
429 with concurrencyMore than 2 (trial) or 8 (full) requests in flightLower your worker count; close unfinished streams
JSON parse errorThe prompt did not describe the keys, or the output was cut offState the schema in the system message and raise max_tokens
Reply cuts off mid-sentencemax_tokens set too lowRaise it, or remove it

If none of these fits, send the value of the X-Request-Id header to support along with what you expected. That ID points to the exact call.

Errors, limits and good habits

A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 and 60. The maximum request body is 8 MB. When you pass a limit, you get HTTP 429 with the error code rate_limited (too many per minute) or concurrency (too many at once). A temporary overload also returns 429, with a Retry-After: 5 header. A simple wrapper handles all three:

import time
from openai import RateLimitError


def ask(messages, tries=4):
    for _ in range(tries):
        try:
            return client.chat.completions.create(model="uncensored", messages=messages)
        except RateLimitError as err:
            time.sleep(float(err.response.headers.get("Retry-After", 5)))
    raise RuntimeError("still rate limited")

Failed or refused requests are not charged, so retries cost nothing extra. Prompts are not used for training.

One rule has no setting that changes it: the service will not produce sexual content involving minors. Everything else is aimed at lawful adult use, such as fiction, roleplay and companion apps. You remain responsible for how you use the output and for the terms of any platform you publish on.

The API is text only. It does not generate images, audio or video, and it does not offer embeddings or fine-tuning. If a project needs those, use another service for that part and keep this one for text.

Ready to go further? The quickstart has the reference details, and top-ups start at $20 with a bonus from $50, paid by crypto only.

Questions and answers

Which Python library should I use?

The official openai package works unchanged once you set the base URL and key. The requests library also works if you prefer to call /v1/chat/completions directly.

What model name do I pass?

Pass "uncensored" as the model value. You can confirm it with GET /v1/models.

Does the API remember earlier messages?

No. You send the full message list on every call, so your code owns the history. The context window is 100,000 tokens.

How do I try it without paying?

Sign up, then claim the $0.50 trial credit with one click on the API key page. It needs no card, is one per person and lasts 7 days.

Is there anything the model will not write?

It will not produce sexual content involving minors. Within lawful adult use, it is tuned to answer without content refusals.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key