EN ▾
Get API key

Build an Unrestricted Chatbot With an OpenAI-Style API

A chatbot without built-in refusals is an ordinary chat app with a different model behind it. This guide builds one on an OpenAI-compatible text API, with streamed replies and a history that fits the 100,000-token window.

Speech bubbles receiving a stream of light from a server cube, illustrating a streaming chatbot API

Updated

Key points

  • Any OpenAI client works: change the base URL and key, and set the model to uncensored.
  • Stream replies with stream: true so text appears as it is generated.
  • Resend the history every turn and trim it before it reaches the 100,000-token limit.
  • A full key allows 8 concurrent requests and 300 requests per minute; handle 429 with a short retry.

What you need to build one

An unrestricted chatbot is a chat interface whose model does not refuse lawful adult requests. You build one by sending the conversation to an OpenAI-compatible endpoint that serves such a model and printing the reply as it streams in. Here the endpoint is https://api.unrestrictedchatbot.com/v1 and the model ID is uncensored.

The model is a single open-weight model run by an independent provider and tuned to answer without content refusals. It is not the official API of any big vendor, and it is not a router across several models. It handles text only, so there is no image or audio output.

The moving parts are small:

  • An API key from the key page, sent as Authorization: Bearer <key>.
  • A list of messages that you keep on your side and send in full with every request.
  • A streaming loop that prints tokens as they arrive.
  • A rule for trimming the list so it never outgrows the context window.

The service does not remember anything between calls. The chat history lives in your program, which is why the trimming rule matters more than it seems.

Step 1: send one request with curl

Before writing any application code, confirm that the key and the endpoint work. This request asks for a short reply and returns a normal chat completion object.

curl https://api.unrestrictedchatbot.com/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [
      {"role": "system", "content": "You are a blunt, funny conversation partner."},
      {"role": "user", "content": "Introduce yourself in two sentences."}
    ]
  }'

If you want to see which model IDs the key can use, call GET /v1/models with the same header. The only ID you need is uncensored.

New accounts can claim $0.50 of trial credit with one click on the key page after sign-up. It needs no payment details, lasts 7 days, and is limited to one per person. That is enough for hundreds of short test messages, so you can finish this whole guide on it.

Step 2: a streaming chat loop in Python

Streaming matters for a chatbot because a long answer can take many seconds, and a blank screen feels broken. With stream: true the server sends tokens over SSE and the SDK exposes them as an iterator.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.unrestrictedchatbot.com/v1",
    api_key="YOUR_API_KEY",
)

history = [
    {"role": "system", "content": "You are Mara, a sarcastic night-shift radio host. Stay in character."}
]

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

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

Two details are easy to miss. First, append the assistant reply to history after the stream ends, otherwise the next turn has no memory of what the bot said. Second, skip chunks with an empty choices list: the final chunk of a stream carries the usage numbers, and it may contain no text.

The same flow in Node is nearly identical.

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.unrestrictedchatbot.com/v1",
  apiKey: process.env.API_KEY,
});

const messages = [
  { role: "system", content: "You are Mara, a sarcastic night-shift radio host." },
  { role: "user", content: "Tell me what the weather is like in your imaginary city." },
];

const stream = await client.chat.completions.create({
  model: "uncensored",
  messages,
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Step 3: keep the history inside 100,000 tokens

The context window is 100,000 tokens, counting the prompt and the completion together. That is a lot of room for a chat, and it is also a trap: because you resend everything each turn, a long session gets slower and more expensive with every message, and eventually it simply does not fit.

Use a simple budget. Pick a ceiling well below the limit, for example 60,000 tokens of history, and drop the oldest user and assistant pairs when you pass it. Never drop the system message, because that is where the character and the rules live.

def trim(history, max_chars=240_000):
    # rough rule: 1 token is about 4 characters of English
    system, rest = history[0], history[1:]
    while rest and sum(len(m["content"]) for m in [system] + rest) > max_chars:
        rest = rest[2:]  # remove the oldest user/assistant pair
    return [system] + rest

# before each request:
# messages = trim(history)
# client = OpenAI(base_url="https://api.unrestrictedchatbot.com/v1", api_key="YOUR_API_KEY")
# client.chat.completions.create(model="uncensored", messages=messages, stream=True)

The four-characters-per-token rule is a rough guess for English and gets worse for other languages and code. If a request is rejected for size, lower the ceiling. For a precise count, read the usage block that comes back with each response and track the prompt tokens it reports.

What a long session costs

Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, so resending history is cheap but not free. Take a 30-turn session where the history averages 6,000 tokens and each reply is about 400 tokens:

  • Input: 30 × 6,000 = 180,000 tokens, which is 0.18 × $0.15 = $0.027.
  • Output: 30 × 400 = 12,000 tokens, which is 0.012 × $0.50 = $0.006.
  • Total: $0.033 for the whole session.

Compare that with the work a session represents: thirty replies, each streamed to the screen, for about three cents. Failed or refused requests are not charged. The full table of numbers is on the pricing page.

Step 4: write a system prompt that sets the character

With refusals out of the way, the quality of the chatbot depends almost entirely on the system message. Vague prompts give vague, flat replies. Specific prompts give a voice.

A useful system prompt answers five questions:

  1. Who is the bot, and what is its situation?
  2. How does it talk: sentence length, slang, humour, formality?
  3. What does it know about the user, and what should it ask?
  4. What should it never do, such as speaking for the user or breaking character?
  5. How long should replies be?

Here is a compact example for a fiction companion app:

You are Mara, a night-shift radio host in a rainy port city. You talk in short, dry sentences and use sailor slang. You never speak for the user and never describe the user's actions. Keep replies under 120 words. If the user steps outside the story to ask a question, answer in one line and return to the scene.

Keep the prompt in one place in your code and test changes by replaying the same five user messages. Small edits to the length rule or the speaking style change the output more than people expect, and a fixed test script is the only way to see it.

For adult-oriented apps, state the audience in your own product copy and require users to confirm they are adults. The model is tuned for lawful adult use. It does not produce sexual content involving minors under any prompt, and you should not try to build anything that would.

Step 5: serve more than one person

A single-user script never hits a limit. A shared bot does. A full key allows 8 concurrent requests and 300 requests per minute, and a trial key allows 2 and 60. A streamed request holds its concurrency slot until the stream ends, so eight people reading eight long answers at the same moment use every slot.

When you go over, the API answers with HTTP 429. The error code is rate_limited for too many requests per minute and concurrency for too many at once. On temporary overload you get a 429 as well, with a Retry-After: 5 header. All three are handled the same way: wait and try again.

import time
from openai import OpenAI, RateLimitError

client = OpenAI(base_url="https://api.unrestrictedchatbot.com/v1", api_key="YOUR_API_KEY")

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

For a web app, put a small queue or a semaphore of 8 in front of the API calls instead of relying on retries alone. Responses also carry X-Balance-USD, so you can show a low-balance warning in your admin screen without a separate call.

Adding tools and structure later

Once the basic loop works, two features turn it from a toy into a product. Tool calling lets the bot ask your code to do something, such as rolling dice, looking up a character sheet or saving a memory note. You pass a tools array, read tool_calls from the reply, run the function, and send the result back as a message with role: "tool".

JSON mode, enabled with response_format: {"type": "json_object"}, helps when part of the bot's job is structured output, for example a summary of the session that you store between visits. Ask for the keys you want in the prompt, and parse the result on your side.

Because the endpoint follows the OpenAI format, existing front ends that accept a custom endpoint can sit on top of it with only the base URL, key and model ID changed. The documentation lists every supported parameter, and the page on the unrestricted API covers the NSFW-oriented integration side in more detail.

On data handling: prompts sent to the API are not used for training. That is a fact about the service, not a promise about your own logs, so decide what your app stores and tell your users.

Questions and answers

Can I use the OpenAI SDK for an unrestricted chatbot?

Yes. Set the base URL to https://api.unrestrictedchatbot.com/v1, use your key, and pass model uncensored. Everything else in the SDK works as documented, including streaming and tool calling.

How long can the conversation get?

The window is 100,000 tokens for prompt and completion together. Your app resends the history each turn, so trim old messages before the total gets close to that number.

Is there a free way to test it?

New users can claim $0.50 of trial credit with one click on the API key page. It needs no payment details, is valid for 7 days and is limited to one per person.

What will the bot still refuse?

The model answers lawful adult requests without content refusals, but sexual content involving minors is a hard limit and stays blocked.

How do I pay for more usage?

Top up any whole amount from $20 to $500 by crypto (USDT on TRC20, USDC on Base). Credit never expires, and larger top-ups add a 5%, 10% or 15% bonus.

Your key is one form away

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