EN ▾
Start now

Grok Unhinged API: Build an Unfiltered Streaming Chatbot

Looking for a grok unhinged api? Whether a vendor exposes a tone mode in its API is something to confirm in its documentation. Here is a hosted alternative that needs no mode at all, plus a complete streaming chatbot you can run in a few minutes.

Last updated

A glowing terminal panel with a stream of luminous speech bubbles flowing across it

Core details

  • The API uses standard OpenAI endpoints, meaning existing client code works with zero refactoring.
  • Pricing is strictly pay-per-token at $0.15 per 1M input and $0.50 per 1M output tokens.
  • Top-ups require cryptocurrency only, accepting USDT on TRC20 or USDC on Base networks.
  • The model serves a 100,000 token context window with no monthly subscription fees.

What to check about a vendor API

A grok unhinged api would be a vendor feature, so the vendor's documentation is the only reliable source on whether one exists and what it does. When you read it, look for three things: whether the mode is a request parameter or an app-only setting, what the content policy says about the API as opposed to the app, and how the pricing differs. We do not guess at any of those here.

What we can describe accurately is our own service. It is a hosted, OpenAI-compatible text API for one open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use. The model ID is uncensored. It is not Grok, not a proxy for it and not a router across vendors. There is no mode parameter; you choose the voice yourself with a system message, and the model does not push back on lawful adult requests.

What we are building

A terminal chatbot with a persistent persona, token-by-token streaming and a history that does not grow without limit. It uses only the official openai package, so the same code will run against any OpenAI-compatible endpoint if you change the base URL.

Before you start, sign up and claim the $0.50 trial credit on the API key page. Then install the package with pip install openai and export your key as UNHINGED_KEY.

The chatbot

import os
import time
from openai import OpenAI, RateLimitError

client = OpenAI(
    base_url="https://api.grokunhinged.com/v1",
    api_key=os.environ["UNHINGED_KEY"],
)

PERSONA = (
    "You are a blunt, funny assistant with no patience for filler. "
    "Answer first, explain after. Swearing is fine when it fits, never at the user. "
    "No disclaimers unless asked. Keep replies under 200 words."
)

history = [{"role": "system", "content": PERSONA}]
MAX_TURNS = 20  # keep the last 20 user/assistant pairs


def trim():
    system, rest = history[0], history[1:]
    del history[:]
    history.append(system)
    history.extend(rest[-MAX_TURNS * 2:])


def reply(text):
    history.append({"role": "user", "content": text})
    for attempt in range(4):
        try:
            stream = client.chat.completions.create(
                model="uncensored",
                messages=history,
                temperature=1.0,
                stream=True,
            )
            parts = []
            for chunk in stream:
                if chunk.choices and chunk.choices[0].delta.content:
                    piece = chunk.choices[0].delta.content
                    parts.append(piece)
                    print(piece, end="", flush=True)
            print()
            history.append({"role": "assistant", "content": "".join(parts)})
            trim()
            return
        except RateLimitError:
            time.sleep(5)
    print("Still rate limited, try again in a moment.")
    history.pop()


while True:
    try:
        text = input("you> ").strip()
    except EOFError:
        break
    if text in ("quit", "exit"):
        break
    if text:
        reply(text)

Run it, and the persona answers as each token arrives. Everything that shapes the voice sits in PERSONA, so you can iterate on tone without touching the loop.

Why each part is there

Streaming

With stream=True the server sends events as they are generated and usage arrives at the end. For a chat interface this makes the first words appear almost immediately instead of after the whole reply. Note that a streamed request keeps its concurrency slot until the stream ends, so always read the loop to completion.

History trimming

Every request resends the history. The context window is 100,000 tokens, shared by prompt and completion, so an endless chat will eventually fail, and well before that it gets expensive. The loop keeps the system message plus the last 20 exchanges. For fiction or long roleplay, replace that with a summary: ask the model to condense old turns into a paragraph and store that as a second system message.

Retrying on 429

The API answers 429 when you pass a limit. The error code rate_limited means too many requests per minute and concurrency means too many at once; on temporary overload it also sends Retry-After: 5. A trial key allows 2 concurrent requests and 60 per minute, a full key 8 and 300. The five-second sleep above matches the retry header.

Putting the bot behind a web endpoint

To serve browsers, wrap the same call in a small server that streams text. This FastAPI example returns the model output as a plain text stream, one history per session id held in memory.

import os
from fastapi import FastAPI
from fastapi.responses import StreamingResponse
from openai import OpenAI

app = FastAPI()
client = OpenAI(
    base_url="https://api.grokunhinged.com/v1",
    api_key=os.environ["UNHINGED_KEY"],
)
SESSIONS = {}

@app.post("/chat/{sid}")
def chat(sid: str, body: dict):
    hist = SESSIONS.setdefault(sid, [{"role": "system", "content": "Blunt, funny, under 200 words."}])
    hist.append({"role": "user", "content": body["text"]})

    def gen():
        parts = []
        stream = client.chat.completions.create(model="uncensored", messages=hist, stream=True)
        for chunk in stream:
            if chunk.choices and chunk.choices[0].delta.content:
                piece = chunk.choices[0].delta.content
                parts.append(piece)
                yield piece
        hist.append({"role": "assistant", "content": "".join(parts)})

    return StreamingResponse(gen(), media_type="text/plain")

Two production notes. First, in-memory sessions vanish on restart, so use a database once real users arrive. Second, the limits are per key, not per user: a full key allows 8 concurrent requests, and each open stream uses one. With more than 8 chats streaming at once you need a queue in front of the API, or the extra requests will get concurrency errors.

Debugging checklist

When the bot misbehaves, work down this list before you change the prompt.

  • Empty replies. Print the raw chunk. The first chunk often carries only a role, with no text, which is normal.
  • Replies cut off. Check finish_reason on the last chunk and any max_tokens you set.
  • Bot forgets earlier turns. Your trim function may be cutting too much. Log the length of the history list.
  • Odd or repeated phrases. Add a frequency penalty near 0.3 or lower the temperature.
  • Sudden 429s. Read the error code. rate_limited is requests per minute, concurrency is too many streams at once.

Keep the X-Request-Id value from the response headers in your logs. If you write to us through the support page, include that ID so the exact call can be found.

What it costs to run

Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens. In the bot above, a late-conversation turn might send 3,000 tokens of history and receive 250 tokens back:

  • Input: 3,000 x $0.15 / 1M = $0.00045
  • Output: 250 x $0.50 / 1M = $0.000125
  • Total: $0.000575, about 0.06 of a cent

The $0.50 trial therefore covers roughly 870 turns of that size. Failed or refused requests are not charged. See the pricing page for top-ups, which run from $20 to $500 in crypto with bonuses from $50.

Taking it further

The same loop moves into a web backend with little change. Replace input() with a request handler, keep one history per user session, and stream the chunks to the browser over SSE. Other additions that are often useful:

  • Tool calling, if the bot should look things up. Pass tools and return results as role: "tool" messages.
  • JSON mode, if another program reads the reply.
  • A moderation layer of your own if the public can talk to the bot. The model does not refuse lawful adult requests, so rules for your audience are yours to set.

Sexual content involving minors is never allowed on this service. The full endpoint reference is in the docs, and the background on persona prompts is in the Grok API alternative guide.

Common questions

Does the vendor offer an official unhinged mode over API?

Check xAI's developer documentation for what its API offers. This site is independent and has no mode parameter; you set the tone with a system message.

Can I stream responses?

Yes. Send stream: true and read server-sent events. Usage is reported at the end of the stream.

How many users can my bot serve at once?

A full key allows 8 concurrent requests and 300 requests per minute. A streamed reply holds its slot until it finishes.

Does the bot have a memory limit?

The context window is 100,000 tokens for prompt plus completion. Trim or summarise old turns well before you reach it.

Get your API key

Register, retrieve your key, and update the base URL. That is all it takes.

Start with trial credit

Sign up with email and password. Key appears instantly.