Uncensored AI API in Python: OpenAI SDK setup
To use an uncensored AI API in Python (what Portuguese speakers search as ia sem censura api), install the OpenAI SDK, point it at https://api.censurasemia.com/v1 and set the model to uncensored. The first request takes about ten lines of code.

Summary
- Install openai, set base_url and your key, and use the model ID uncensored.
- Streaming, JSON mode and tool calling use the standard OpenAI parameters.
- Handle HTTP 429 by waiting for Retry-After and retrying, and keep concurrency at or below 8.
- Prompts in Portuguese are plain UTF-8 text; test the output quality with your own examples.
Step 1: get a key and install the SDK
Create an account with Google, or with email and password, then open the API key page. New users can claim $0.50 of trial credit there with one click. It needs no card, lasts 7 days and is limited to one per person. The trial key allows 2 concurrent requests and 60 requests per minute, enough to follow this guide.
Then install the official SDK and keep the key out of your source code:
pip install openai
export CENSURA_KEY="paste-your-key-here"
The service is a hosted, OpenAI-compatible text API. The model behind it is a single open-weight model run by an independent provider, tuned to answer without content refusals for lawful adult use. It is not an official API of any big vendor, and it does not route between vendors.
Step 2: your first request
Save this as primeira.py. The only differences from a standard OpenAI script are the base URL and the model name.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.censurasemia.com/v1",
api_key=os.environ["CENSURA_KEY"],
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "Responda sempre em portugues do Brasil, de forma direta."},
{"role": "user", "content": "Escreva uma cena curta de suspense num porto a noite."},
],
temperature=0.8,
)
print(resp.choices[0].message.content)
print(resp.usage)
Run python primeira.py. The usage object shows prompt and completion tokens, which you can multiply by the prices ($0.15 and $0.50 per 1M tokens) to see what the call cost. There is no max_tokens requirement: the completion may use whatever is left of the 100,000-token window, so set max_tokens yourself if you want a hard cap on length and cost.
Step 3: stream the answer
For a chat window or terminal tool you want words to appear as they are generated. Add stream=True and read the chunks. The final chunk carries usage when you request it.
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Explique o que e um token em duas frases."}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
if getattr(chunk, "usage", None):
print("\ntokens:", chunk.usage.total_tokens)
A streamed request holds one of your concurrency slots until the stream ends. If you open streams in threads, cap them at 8 on a full key, or 2 on a trial key.
Step 4: JSON output and tools
When your program needs structured data, use JSON mode. Describe the fields in the prompt, because JSON mode guarantees valid JSON syntax, not your schema.
import json
r = client.chat.completions.create(
model="uncensored",
response_format={"type": "json_object"},
messages=[
{"role": "system", "content": "Devolva JSON com as chaves: titulo, personagens (lista), tom."},
{"role": "user", "content": "Ideia: um detetive aposentado encontra uma carta antiga."},
],
)
dados = json.loads(r.choices[0].message.content)
print(dados["titulo"])
Tool calling also follows the OpenAI format: pass tools and tool_choice, read tool_calls from the reply, run your function and send the result back as a message with role set to tool. Details and examples are in the API documentation.
Step 5: retries and rate limits
A full key allows 8 concurrent requests and 300 requests per minute. Beyond that the API answers HTTP 429. The error code rate_limited means too many requests per minute, and concurrency means too many at once. On temporary overload you also get 429 with a Retry-After: 5 header. A small wrapper handles all three:
import time
from openai import RateLimitError
def pedir(messages, tentativas=4):
for i in range(tentativas):
try:
return client.chat.completions.create(model="uncensored", messages=messages)
except RateLimitError as e:
espera = int(e.response.headers.get("Retry-After", 5))
time.sleep(espera * (i + 1))
raise RuntimeError("limite de requisicoes persistente")
Failed or refused requests are not charged, so retrying does not double the bill. The response headers X-Request-Id, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency and X-Balance-USD are useful to log. Quote the request ID if you contact support.
The same call in Node.js and curl
If part of your stack is not Python, the request is identical. With the official Node package:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.censurasemia.com/v1",
apiKey: process.env.CENSURA_KEY,
});
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Resuma a trama de Dom Casmurro em tres linhas." }],
});
console.log(resp.choices[0].message.content);
And with curl, which is handy for checking that a key works before you write any code:
curl https://api.censurasemia.com/v1/chat/completions \
-H "Authorization: Bearer $CENSURA_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"uncensored","messages":[{"role":"user","content":"Ola"}]}'
You can also list the available model with GET /v1/models. If that call returns a 401, the key is wrong or has a stray space; if it returns a 429, you hit a limit.
Portuguese prompts: practical notes
Nothing special is needed to send Portuguese. The text is UTF-8, accents included. Some habits make results steadier:
- State the language and variant in the system message, for example "portugues do Brasil" or "portugues europeu".
- Keep one language per prompt. Mixing instructions in English with an answer expected in Portuguese works, but say so explicitly.
- Run a few of your real prompts before you commit. Output quality in any language depends on your task, so judge it on your own examples rather than on a claim from us.
Accented characters cost about the same as other text, but token counts differ by language, so measure with resp.usage instead of guessing from the number of words.
Mistakes that waste time
Most first-day problems with an uncensored AI API in Python come from a short list of causes. Check these before you suspect the service.
- Forgetting the history. The API does not remember earlier requests. For a chat, keep a list of messages and send the whole list each time, adding the reply after every turn.
- A wrong base URL. The SDK needs the address up to
/v1, without/chat/completionsat the end. A not-found error usually means the path was doubled or cut. - A key in the source file. Keep it in an environment variable, as in step 1. If a key ever leaks, open the API key page and regenerate it. The old key stops working at once, and no support ticket is needed.
- Unbounded threads. A loop that fires 50 requests at once will hit the
concurrencyerror. Use a semaphore.
For batch jobs, the async client with a semaphore keeps you inside the limit without extra code:
import asyncio, os
from openai import AsyncOpenAI
client = AsyncOpenAI(
base_url="https://api.censurasemia.com/v1",
api_key=os.environ["CENSURA_KEY"],
)
gate = asyncio.Semaphore(6)
async def uma(texto):
async with gate:
r = await client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": texto}],
max_tokens=300,
)
return r.choices[0].message.content
async def main():
textos = ["Resuma em uma frase: " + t for t in ["O mar", "A cidade", "O trem"]]
for resp in await asyncio.gather(*(uma(t) for t in textos)):
print(resp)
asyncio.run(main())
The semaphore is set to 6, which leaves two slots free on a full key for anything else your program does. On a trial key, lower it to 2. Setting max_tokens here caps the cost of each reply, which is a sensible habit for any batch where you know the answers should be short.
One more habit: save the raw responses to disk while you develop. When a prompt behaves oddly, having the exact input and the X-Request-Id value next to the output turns a vague complaint into something you can reproduce in a minute.
Cost, balance and next steps
A typical call with a 500-token prompt and a 400-token answer costs 500 x $0.15 / 1M + 400 x $0.50 / 1M = $0.000075 + $0.0002 = $0.000275. That is about 3,600 calls for a dollar. The cost and trade-off analysis goes through larger scenarios, and the pricing page lists top-ups, which run from $20 to $500 in crypto (USDT on TRC20 or USDC on Base), with bonuses of 5%, 10% and 15% at the higher tiers.
Check your remaining credit with GET /v1/balance, or read the X-Balance-USD header. Prompts are not used for training. Only lawful adult use is allowed, and content involving minors is blocked without exception. This is a text API: there is no image, audio or video generation and no embeddings.
More guides
FAQ
Do I need a special library besides the OpenAI SDK?
No. Any OpenAI-compatible client works. You change the base URL, the key and the model ID, which is uncensored.
Can I use Node.js or curl instead of Python?
Yes. The endpoints and parameters are the same, so the official OpenAI Node package or a plain curl request with a Bearer header both work.
Does the API understand Portuguese?
You can send and receive Portuguese text. How well it fits your task is something to test with your own prompts.
How long does the trial credit last?
Seven days from the moment you claim it, one claim per person, and it needs no card.
Generate your API key
Sign up, copy the key, update your endpoint URL. That is all.