Prerequisites and Authentication
To begin using Apertus, you need an API key and the correct base URL. Sign up via the Get API key page using Google or email/password to receive your key immediately. No phone number or credit card is required for the initial trial credit.
Configure your OpenAI-compatible client with the base URL https://api.apertus.cc/v1 and set your API key as the authorization bearer token. This setup ensures that your existing client code works without modification, provided you are using the OpenAI SDK or any compatible library.
First Request with cURL
Verify your integration with a simple text completion request. The following command sends a prompt to the uncensored model and returns a direct text response. This confirms that your API key is valid and the endpoint is reachable.
- Endpoint:
POST /v1/chat/completions - Model ID:
uncensored
curl https://api.apertus.cc/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
}'
Python SDK Integration
Use the official OpenAI Python library to interact with Apertus. Override the base URL to point to our service while keeping the same method signatures. This allows you to leverage familiar SDK patterns for prompt engineering and response handling.
- Install the library:
pip install openai - Set the base URL in the client initialization
from openai import OpenAI
client = OpenAI(base_url="https://api.apertus.cc/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)
Node.js SDK Integration
For JavaScript environments, install the OpenAI package and configure the base URL. This approach works with any Node.js application that supports OpenAI-compatible clients. Ensure you handle asynchronous responses correctly, as the API returns standard JSON objects.
- Install:
npm install openai - Configure
baseURLandapiKey
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.apertus.cc/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);
Streaming Responses
Enable streaming by setting stream: true in your request. The API returns a Server-Sent Events (SSE) stream, delivering tokens as they are generated. This reduces perceived latency and allows you to display partial results to users in real time. Token usage statistics are included in the final chunk.
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)
Limits, Errors, and Context
Monitor your usage against the following limits: 300 requests per minute per key and 8 concurrent requests. The context window supports up to 64,000 tokens total, with a maximum output of 16,000 tokens per request. Errors like 401 (invalid key) or 402 (no credit) are free. Refusals are also free, but hard content limits always apply.