Install the standard OpenAI SDK
Start by installing the official SDK for your preferred language. This library handles authentication and request formatting automatically. It works with our uncensored LLM API without modifications.
- Python:
pip install openai - Node.js:
npm install openai
The SDK version must be recent enough to support the base_url parameter. This ensures compatibility with our OpenAI compatible API structure.
Set your base URL and API key
Configure the client to point to our servers. Use the base URL https://api.unrestrictedaibot.com/v1 and your unique API key. This setup allows you to use the same code you already have for other services.
Authentication is passed via the Authorization header. The SDK handles this header injection automatically when you provide the key.
curl https://api.unrestrictedaibot.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Find all null values in this JSON response"}]
}'
Send your first chat completion
Make a request to /v1/chat/completions with the model ID uncensored. Send a user message and receive a text response. This model does not refuse lawful adult topics or controversial content.
Set the max_tokens parameter to control output length. The default is 2,048 tokens if you omit this field. Our context window supports up to 100,000 tokens total.
from openai import OpenAI
client = OpenAI(base_url="https://api.unrestrictedaibot.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)
Enable streaming responses
Use Server-Sent Events (SSE) for real-time token delivery. Set stream=true in your request. The SDK yields tokens as they are generated. This reduces perceived latency for long responses.
Handle the stream chunks in your code. The final chunk contains the total token usage. This is useful for billing transparency and monitoring consumption.
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Use JSON mode and function calling
Request structured output by setting response_format to {"type": "json_object"}. The model returns valid JSON that you can parse directly. This is ideal for building agents or data pipelines.
Define tools in your request for function calling. The model can invoke functions based on the user prompt. Use tool_choice to control when functions are called. This adds power to your applications without extra infrastructure.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.unrestrictedaibot.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);
Check your token usage and limits
Monitor your usage via the API response headers or the final stream chunk. You are charged per token used. Errors and refusals are free. This transparent pricing model applies to all requests.
Respect the rate limits: 300 requests per minute and 8 concurrent requests per key. If you exceed these limits, you will receive a 429 error. Plan your concurrency accordingly.