Prerequisites: Install the SDK
Install the official SDK for your preferred language to handle authentication and request formatting automatically. Most developers prefer the community-maintained packages that mirror the standard openai library structure. This ensures your code remains compatible with future updates to the chat-completions endpoint.
from openai import OpenAI
client = OpenAI(base_url="https://api.openaiapikeypricing.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)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.openaiapikeypricing.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);
Set Your Base URL
Point your client to our specific base URL to route requests through our uncensored infrastructure. You must update the base_url parameter in your client configuration before sending any requests. This tells the SDK to skip the standard OpenAI servers and direct traffic to our dedicated endpoints.
The base URL is: https://api.openaiapikeypricing.com/v1
Initialize the Client
Create an instance of your client using your API key obtained from the dashboard. Pass the key as a string and set the base URL to ensure all requests are directed correctly. This step establishes the connection context for subsequent API calls without requiring additional configuration.
from openai import OpenAI
client = OpenAI(base_url="https://api.openaiapikeypricing.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)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.openaiapikeypricing.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);
Make Your First Chat Completion
Send a simple text prompt to the /v1/chat/completions endpoint to verify your integration. Use the model ID uncensored to access the open-weight model tuned for adult and controversial topics without refusals. The API returns a standard completion object containing the generated text.
curl https://api.openaiapikeypricing.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "List the token costs for ten model variants"}]
}'
Handle Streaming Responses
Enable streaming by setting stream: true to receive tokens as they are generated. This reduces perceived latency for long-form content or interactive applications. The SDK handles the Server-Sent Events (SSE) parsing, delivering each token to your event handler.
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
Your key supports 300 requests per minute and allows a context window of 100,000 tokens. Monitor for HTTP 401 errors if the key is invalid, 402 errors if prepaid credit is exhausted, and 429 errors if you exceed the rate limit. Requests exceeding the 8 MB body size or 16,000 token output limit will also return errors.