How to Use an OpenAI-Compatible API in 5 Steps
Using an OpenAI-style API takes five moves: get a key, install an SDK, point it at the right base URL, name a model and send messages. Here is each one with code you can paste.

Key points
- Any OpenAI SDK works here once you change the base URL to https://api.uncensoredaiapis.com/v1 and use your own key.
- The model ID is uncensored; the main routes are POST /v1/chat/completions and GET /v1/models.
- Streaming, JSON mode and tool calling use the same parameters as the official API.
- Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens, and you can start with $0.50 trial credit.
The short version
If you want to know how to use openai api calls with a service that is not OpenAI, the answer is that the request format is a shared convention. A client that speaks it needs three values: where to send requests (the base URL), who you are (the key) and which model to run. Change those three and the same code works. This site follows that convention, so the standard OpenAI Python and Node packages, and plain curl, all work against it.
Be clear about what that does and does not mean. Compatible means the interface matches. It does not mean this is the official OpenAI service or that it runs OpenAI models. The backend is one open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use, and you select it with the model ID uncensored. It handles text only: no images, audio, embeddings or fine-tuning.
The five steps below take about ten minutes. If you prefer to read finished snippets in several languages, see the code examples page.
Step 1: get a key
Sign up with Google, or with email and password, and open the API key page. New users can claim $0.50 of trial credit with one click. It is valid for 7 days, limited to one per person, and needs no card. Copy the key and store it as an environment variable instead of pasting it into code:
# base URL used below: https://api.uncensoredaiapis.com/v1 , model: uncensored
export API_KEY="paste-your-key-here"The trial key is limited to 2 concurrent requests and 60 requests per minute. A funded key allows 8 concurrent and 300 per minute. The details of what the trial includes are in the free trial FAQ.
Step 2: install an SDK and send the first request
Install the official package for your language. Both of these are the same libraries you would use for any OpenAI-style service:
# base URL used below: https://api.uncensoredaiapis.com/v1 , model: uncensored
pip install openai
npm install openaiNow a first call in Python. The only difference from the default setup is the base_url argument:
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.uncensoredaiapis.com/v1",
api_key=os.environ["API_KEY"],
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a concise writing assistant."},
{"role": "user", "content": "Give me three titles for a noir short story."},
],
)
print(resp.choices[0].message.content)And the same call in Node:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.uncensoredaiapis.com/v1",
apiKey: process.env.API_KEY,
});
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Give me three titles for a noir short story." }],
});
console.log(resp.choices[0].message.content);Step 3: understand the messages array
Chat models do not remember anything between calls. Each request carries the whole conversation as a list of messages, and each message has a role.
systemsets behavior and style. Put the persona, format rules and constraints here.userholds what the person asked.assistantholds the model's earlier replies. You add these yourself when you continue a conversation.toolcarries the result of a function call, covered below.
To continue a chat, append the assistant's reply and the next user message to the same list and send it all again. This is why long conversations cost more: every call pays for the full history as input tokens. The window holds 100,000 tokens in total, prompt and completion together, so trimming old turns is a normal part of building a chat app.
Useful sampling fields are passed through: temperature, top_p, stop, seed and the frequency and presence penalties. max_tokens is optional. Set it when you want to cap reply length and spend.
Step 4: streaming, JSON mode and tools
Streaming
Add stream: true to receive tokens as server-sent events. It makes interfaces feel fast, since text appears while the model is still writing, and usage is reported at the end of the stream.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.uncensoredaiapis.com/v1", apiKey: process.env.API_KEY });
const stream = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Write a short toast for a retirement party." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}JSON mode
Use response_format: {"type": "json_object"} when your code parses the reply. Describe the wanted keys in the prompt as well.
curl https://api.uncensoredaiapis.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"response_format": {"type": "json_object"},
"messages": [
{"role": "system", "content": "Reply with JSON: {\"mood\": string, \"score\": number}"},
{"role": "user", "content": "Rate this line: the rain finally stopped."}
]
}'Tool calling
Pass a tools list with function schemas, and optionally tool_choice. When the model wants a function run, the reply contains tool_calls. You run the function in your own code and send the output back as a message with role tool. Tool calls also stream. This is the building block for agents; the use cases page shows where that pays off.
Step 5: know the limits, costs and errors
Over a limit, the API returns HTTP 429. The error code is rate_limited for too many requests per minute and concurrency for too many at once. A temporary overload also gives a 429, with a Retry-After: 5 header. A streamed request keeps its concurrency slot until the stream ends, so close streams you no longer read. The body limit is 8 MB. Every response carries X-Request-Id and X-Balance-USD headers, and the first is what you quote to support.
Costs are simple. A chat call with 3,000 input tokens and 700 output tokens costs 3,000 times $0.15 per million, which is $0.00045, plus 700 times $0.50 per million, which is $0.00035, so $0.0008 in total. A thousand such calls cost $0.80. Failed or refused requests are not charged, and credit never expires. The pricing page lists top-ups from $20 to $500 with +5% from $50, +10% from $100 and +15% from $200. You can pay with crypto (USDT on TRC20, USDC on Base).
How this differs from the official API
Three differences are worth planning for. First, the model name: use uncensored, not an OpenAI model name. Second, scope: you get chat completions and the model list only, so features like image generation, speech, embeddings and fine-tuning are not here. Third, behavior: the model is tuned not to refuse lawful adult requests, so output can differ from a heavily filtered assistant. One rule never changes: no sexual content involving minors.
A few habits help on day one. Keep the key in an environment variable, log the X-Request-Id of every call, and set max_tokens while you experiment so a runaway reply cannot spend more than you planned. When you build a chat interface, stream the reply and trim old turns once the history grows. When you build a pipeline that parses output, use JSON mode and still guard the parsing, because a reply cut off at the token limit is not valid JSON. And when two parts of your program call the API at the same time, count them against the 8 concurrent requests a full key allows.
Do not forget the cost of testing. A few dozen experiments with short prompts cost far less than one cent in total, so the $0.50 trial credit goes a long way while you learn the request format.
If you are moving an existing app, the migration guide walks through the changes in order. Prompts sent here are not used for training. For most apps the migration is the three values from the start of this page and a model name.
More guides
Questions and answers
Do I need the official OpenAI SDK?
You can use it, and it is the easiest route. Any OpenAI-compatible client or plain HTTP works too, as long as it supports a custom base URL.
What model name do I send?
Send uncensored. The base URL is https://api.uncensoredaiapis.com/v1.
Is this the official OpenAI API?
No. It follows the same request format, but the model is an open-weight model run by an independent provider, and the service is separate from OpenAI.
How much does a request cost?
Input tokens cost $0.15 per 1M and output tokens $0.50 per 1M. A request with 3,000 input and 700 output tokens costs about $0.0008.
Can I try it before paying?
Yes. After sign-up you can claim $0.50 of trial credit with one click. It is valid for 7 days and needs no card.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.