Base URL and Authentication
Connect to the API using the provided base URL and your API key. This endpoint works with standard OpenAI SDKs by simply updating the configuration. You receive one active key per account, which you generate via Google or email during signup. The key authenticates every request you make to the service.
curl https://api.hubuncensored.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Generate a JSON object with user id and role"}]
}'Keep your key secure. If you generate a new one, the previous key becomes invalid immediately. This ensures you always control access to your prepaid credit without lingering permissions.
Chat Completions Endpoint
Send your prompt data to the chat completions endpoint for text generation. This is the primary interface for your applications, handling all text input and output. You must specify the model as 'uncensored' to ensure consistent behavior. The API processes your request and returns the generated text response.
from openai import OpenAI
client = OpenAI(base_url="https://api.hubuncensored.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)Errors like 401 indicate an invalid key, while 402 means you need more credit. Requests are charged based on actual token usage, so errors do not drain your balance.
Streaming Responses via SSE
Receive tokens in real-time using Server-Sent Events (SSE). This method reduces perceived latency for long outputs by delivering data as it is generated. You can parse the final chunk to get accurate token usage statistics for billing. Streaming is ideal for user-facing interfaces where immediate feedback matters.
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)The context window allows for 100,000 tokens total, including both prompt and completion. Streaming does not change the underlying token limits or pricing structure.
Function Calling and JSON Mode
Use function calling to integrate structured outputs into your workflow. Specify tools and tool_choice to guide the model's response format. You can also enforce strict JSON mode using the response_format parameter for reliable parsing. This ensures your application receives data in the exact structure you define.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.hubuncensored.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);These features work within the single uncensored model. There is no model routing or choice between different vendors. You rely on one open-weight model tuned for unrestricted content.
Parameters: Temperature, Top P, and Stop
Control generation behavior with standard parameters like temperature and top_p. Adjust these values to balance creativity and determinism in your outputs. The stop parameter allows you to halt generation at specific sequences. You can also set presence_penalty and frequency_penalty to refine output style.
Set max_tokens to 16,000 for long responses. If you omit max_tokens, the default is 2,048 tokens per request. These settings give you precise control over the generation process.
Limits, Errors, and Context Window
Monitor your usage against strict rate limits to ensure smooth operation. You are allowed 300 requests per minute and 8 concurrent requests per key. The maximum request body size is 8 MB. Exceeding these limits returns a 429 rate limit error. Understanding these constraints helps you design robust retry logic.
The context window supports 100,000 tokens total. This includes both the input prompt and the generated completion. Plan your token usage accordingly to avoid truncation or errors.