Summary of the spec
If you already have code that talks to OpenAI, the short version of the openai compatible api spec is this: change the base URL, change the key, set the model to uncensored. Request and response bodies follow the chat completions shape, so SDKs parse them without changes.
| Item | Value |
|---|---|
| Base URL | https://api.unrestrictedaiapi.com/v1 |
| Auth | Authorization: Bearer YOUR_KEY |
| Methods | POST /v1/chat/completions, GET /v1/models |
| Model ID | uncensored |
| Context window | 100,000 tokens, prompt plus completion |
| Max request body | 8 MB |
| Output | Text only |
The model is a single open-weight model run by an independent provider and tuned to answer without content refusals for lawful adult use. It is not the official endpoint of any model vendor and it does not route between vendors. That is why there is one model ID and why the model list is short.
Endpoints
GET /v1/models
Returns the models available to your key. It is the cheapest way to confirm that your key and base URL are right, and many UI clients call it to fill a dropdown.
curl https://api.unrestrictedaiapi.com/v1/models \
-H "Authorization: Bearer $KEY"
POST /v1/chat/completions
The only generation endpoint. You send a messages array of objects with a role (system, user, assistant or tool) and content, plus the model and any sampling options. A minimal call:
curl https://api.unrestrictedaiapi.com/v1/chat/completions \
-H "Authorization: Bearer $KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [
{"role": "system", "content": "Answer in one sentence."},
{"role": "user", "content": "What is a base URL?"}
]
}'
The reply carries the generated text in choices[0].message.content and token counts in usage. Those counts are what billing is based on.
Not offered: the legacy completions endpoint, embeddings, image, audio and video endpoints, fine-tuning and file endpoints. A client that calls them will receive an error, so disable those features in tools that default to using them.
Request parameters
These parameters are accepted and passed through to the model:
temperatureandtop_pfor sampling.stopfor one or more stop sequences.seedfor repeatable sampling when you keep everything else equal.presence_penaltyandfrequency_penaltyto reduce repetition.max_tokens, which is optional. If you leave it out, the completion can use the rest of the 100,000-token window.streamfor server-sent events.toolsandtool_choicefor function calling.response_formatwith{"type":"json_object"}for JSON mode.
Two practical notes. First, the window counts prompt and completion together, so a 90,000-token prompt leaves about 10,000 tokens for the answer. Second, the body limit is 8 MB, which is far more than 100,000 tokens of text needs, so you only reach it by embedding large encoded payloads in messages.
Streaming
Set stream: true and the response arrives as server-sent events. Each event is a JSON chunk with a delta holding the next piece of text, and usage is reported at the end of the stream. SDKs hide the framing; with the raw protocol you read lines that begin with data: until the stream closes.
from openai import OpenAI
client = OpenAI(base_url="https://api.unrestrictedaiapi.com/v1", api_key="YOUR_KEY")
with client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "List five HTTP status codes."}],
stream=True,
) as stream:
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
One rule affects capacity planning: a streamed request holds its concurrency slot until the stream ends, not until the first token. If a client stalls while reading, it keeps the slot busy. Always close or finish the stream, and set a client timeout.
Tool calling and JSON mode
Tool calling
Pass tools as a list of function definitions with JSON Schema parameters. If the model decides to call one, the message contains tool_calls, which are also streamed when stream is on. You run the function and send back its result as a message with role: "tool" and the matching tool_call_id. Use tool_choice to force a particular function or to leave the decision to the model.
{
"model": "uncensored",
"messages": [{"role": "user", "content": "Weather in Oslo?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
}
The model proposes arguments; it does not execute anything. Validate them before you act on them, as you would with any user input.
JSON mode
Add "response_format": {"type": "json_object"} to ask for a single valid JSON object. As with other OpenAI-style implementations, also tell the model in the prompt what keys you want, for example "Return an object with keys title and tags". Parse the result in a try block anyway, and keep max_tokens generous so a long object is not cut off.
Limits, headers and errors
| Key type | Concurrent requests | Requests per minute |
|---|---|---|
| Full key | 8 | 300 |
| Trial key | 2 | 60 |
Every response includes X-Request-Id (quote it when you contact support), X-Balance-USD (your remaining credit), X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency.
When you pass a limit the API returns HTTP 429. The error code separates the cases:
rate_limited: too many requests in a minute. Slow down or spread the load.concurrency: too many requests in flight at once. Queue them on your side.- 429 with a
Retry-After: 5header: temporary overload. Wait five seconds and retry.
import time
import httpx
def post_with_retry(payload, key, tries=4):
# payload example: {"model": "uncensored", "messages": [...]}
for attempt in range(tries):
r = httpx.post(
"https://api.unrestrictedaiapi.com/v1/chat/completions",
headers={"Authorization": "Bearer " + key},
json=payload,
timeout=120,
)
if r.status_code == 429:
wait = int(r.headers.get("Retry-After", 2 ** attempt))
time.sleep(wait)
continue
return r
return r
Requests that fail or are refused are not charged.
Roles, history and the response object
The API is stateless. It does not remember earlier requests, so a conversation exists only as the messages array you send each time. A typical history starts with one system message that sets behaviour, followed by alternating user and assistant messages. When tool calling is in play, tool messages appear between them, each linked to the call it answers by tool_call_id.
This has two consequences. The first is cost: every turn pays for the entire history as input, so a long chat gets more expensive per message even if each question is short. The second is control: you can edit, trim or rewrite history at will. Dropping the oldest turns, replacing them with a summary or injecting a corrected assistant message are all ordinary operations, and the model treats whatever you send as the truth.
On the way back, read three things. choices[0].message holds the text or the tool calls. choices[0].finish_reason tells you why generation stopped: a natural end, the token limit, or a tool call. usage holds prompt, completion and total token counts. If the finish reason says the token limit was hit, the text is truncated, and you should either raise the limit or ask the model to continue in a follow-up turn.
A short compatibility checklist
Before you ship a client against this endpoint, run through these checks. They catch most integration problems in a few minutes.
- Call
GET /v1/modelswith your key and confirm you get a list that includesuncensored. - Send a plain chat request without options and confirm a normal reply with a
usageblock. - Repeat it with
stream: trueand confirm that your client handles the end of the stream and the final usage data. - If you use tools, send one tool-call round trip end to end, including the follow-up request with the
toolmessage. - Fire 10 requests at once on a trial key and confirm your code copes with the 429 that follows the second concurrent request.
- Log
X-Request-Idfor every call so that any odd result can be traced later.
Passing all six means your client is ready for real traffic.
Where this differs from the full OpenAI platform
Compatibility means the chat protocol, not the whole platform. Anything outside text chat is absent, and a few behaviours come from the model rather than the protocol. The model name is fixed, answers can differ in style from any model you used before, and sampling with the same seed is repeatable only while the prompt and parameters stay the same.
The one content rule you cannot change is that sexual content involving minors is blocked. Beyond that, the model is tuned to avoid refusals for lawful adult use, and prompts are not used for training.
For code in five languages see the quickstart, for prompt techniques read prompting an unrestricted model, and for the account side, pricing lists the rates: $0.15 per 1M input tokens and $0.50 per 1M output tokens, with credit that never expires. The docs hold the same spec in short form.
