Authenticate and Configure Base URL
Your API key grants immediate access to the chat completions endpoint. Generate a key via Google or email on the dashboard and paste it into your environment variables. The base URL is https://api.cheapaiapikeys.com/v1 which works with any standard OpenAI SDK client.
- Set
OPENAI_API_KEYto your generated string. - Override
base_urlto point to our hosted server. - Verify connectivity by calling
GET /v1/modelsto list available models.
curl https://api.cheapaiapikeys.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "List three common regex patterns for validating email addresses"}]
}'
Send Your First Chat Completion Request
Send text input and receive generated text using the standard chat completion structure. Our single uncensored model processes requests without refusing lawful adult or controversial topics. You can adjust parameters like temperature and top_p to control randomness.
from openai import OpenAI
client = OpenAI(base_url="https://api.cheapaiapikeys.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 and Handle SSE Events
Enable real-time token delivery by setting stream: true in your request. The server returns Server-Sent Events (SSE) that you must parse incrementally. Token usage details appear in the final chunk of the stream. This approach reduces perceived latency for long responses.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.cheapaiapikeys.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);
Use Function Calling and JSON Mode
Define tools in your request payload to enable structured output or external function execution. Use response_format: {type: "json_object"} to force strict JSON compliance. The model supports tool_choice for precise control over which functions it invokes. This ensures reliable parsing for your application logic.
Understand Token Limits and Pricing
Pricing is transparent at $0.15 per million input tokens and $0.50 per million output tokens. Errors and refusals do not consume credit. The context window supports 100,000 tokens total. Requests exceeding the limit return a 429 rate limit error. Ensure your payloads stay under 8 MB to avoid body errors.
Handle Errors and Edge Cases
Common errors include 401 for invalid keys and 402 for insufficient credit. A 429 status indicates you have exceeded 300 requests per minute. Use exponential backoff when retrying after rate limits. Check the error object in the JSON response for specific details. Refunds are not issued, so monitor your usage closely.
Streaming
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)