Quickstart: Integrate apertus ai chat
Integrate the uncensored model with a single base URL and one API key. Drop into any OpenAI-compatible SDK and start generating text immediately.
Prerequisites and Setup
Start by creating an account and obtaining your API key. Sign up using Google or an email password on the key generation page. The system displays your key immediately, so you can copy it without delay. No phone number is required for registration. You receive $0.50 in trial credit valid for seven days, so you can test connectivity without adding funds.
Configure your environment variable or SDK client to point to the correct base URL. This URL works with standard OpenAI libraries. Change only the base URL and your key. The model ID is "uncensored". This single endpoint handles all text completions. You do not need to manage routing or select different models.
Ensure your client library supports the OpenAI Chat Completions protocol. Most modern SDKs work out of the box. Verify your network allows outbound HTTPS requests. The service accepts standard JSON payloads. No special headers are needed beyond authentication.
Authentication with API Keys
Pass your API key in the Authorization header for every request. Use the Bearer scheme followed by your key string. The service validates the key against your account. Invalid keys return a 401 Unauthorized error. Expired or insufficient funds trigger a 402 Payment Required response. Check your balance in the dashboard if requests fail.
Keep your key secure. Each account holds one active key. Generating a new key invalidates the previous one. Do not share your key in public repositories. The API key is the sole identifier for your usage. Rate limits apply per key, not per account.
curl https://api.apertusaichat.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Set role to assistant"}]
}'Authentication is stateless. The server checks the token on every call. If you rotate your key, update all running clients immediately. Missing the header results in immediate rejection. The error message clearly states the authentication failure.
Sending Your First Request
Send a POST request to the chat completions endpoint. Include the model ID "uncensored" and your message history. The API returns a text response. You can stream the output or wait for the full completion. Each request consumes input and output tokens. Errors do not charge credits. Refusals are free.
from openai import OpenAI
client = OpenAI(base_url="https://api.apertusaichat.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)The response includes usage statistics. Track token consumption to manage your prepaid credit. The model answers without content refusals for lawful adult use. You can send system prompts to define behavior. User messages drive the conversation. The context window supports 100,000 tokens total.
Start with a simple two-message exchange. This verifies connectivity and response quality. Adjust temperature and top_p for creative or precise outputs. The API supports standard parameters. Stop sequences work as expected. Seed values ensure reproducible results.
Streaming Responses via SSE
Enable streaming by setting the stream parameter to true. The API returns Server-Sent Events (SSE) instead of a single JSON object. Each chunk contains a portion of the generated text. Read chunks until the stream ends. The final chunk includes total token usage.
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)Streaming reduces perceived latency. Users see text appearing in real time. This is ideal for chat interfaces. Handle partial tokens carefully. Concatenate chunks to form the complete response. The server closes the connection when generation finishes.
Monitor stream errors. Network interruptions may abort the stream. Implement reconnection logic if needed. The API does not resend history. Start a new request if the stream fails. Token counts in the last chunk reflect the entire generation.
Handling Parameters and Modes
Use standard parameters to control generation. Set temperature for randomness. Adjust top_p for nucleus sampling. Define stop sequences to halt generation early. Pass a seed for deterministic outputs. Enable JSON mode by setting response_format to json_object. The model returns valid JSON when requested.
Function calling is supported. Define tools in the request. The model returns tool calls when appropriate. Parse the tool arguments in your code. Pass results back to continue the conversation. This enables complex agent workflows.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.apertusaichat.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);Max tokens limit the output length. Default is 2,048 tokens. Set a higher value if needed. The hard limit per request is 16,000 tokens. Context window is 100,000 tokens. Plan your history length accordingly. Frequency and presence penalties help reduce repetition.
Understanding Limits and Errors
Rate limits protect service stability. You can send 300 requests per minute. Concurrency is limited to eight simultaneous requests per key. Request bodies must not exceed 8 MB. Exceeding limits returns a 429 Too Many Errors. Wait before retrying.
Check error codes for diagnostics. 401 means invalid or missing key. 402 indicates insufficient prepaid credit. Top up via crypto to resume service. 429 signals rate limiting. 400 denotes bad request syntax. Review the error message for details.
Context window management is critical. Sum prompt and completion tokens. Stay well below 100,000 tokens. Truncate old messages if needed. The API does not auto-truncate. You control the history length. Efficient context usage reduces costs.
Common questions
How do I debug missing citations in parallel chat API responses?
The uncensored model does not natively provide citations. It generates text based on training data. If you need citations, you must implement a retrieval-augmented generation (RAG) system yourself. Pass relevant documents in the context window and instruct the model to reference them.
Can I use this API with TypingMind?
Yes, the API is OpenAI-compatible. Set the API type to OpenAI Chat Completions. Use the base URL HTTPS://api.apertusaichat.com/v1. Enter your API key in the authorization field. Select the model "uncensored". This configuration works with most OpenAI-compatible clients.
What happens if I exceed my token limit?
The API returns a 400 Bad Request error if the total tokens exceed the context window. The limit is 100,000 tokens for prompt plus completion. You must reduce the message history or token count. Errors and refusals do not consume tokens. Check the usage field in the response to track consumption.
Get your API key now
Register, copy the token, update your base URL. Setup is complete.