OpenAI Compatible REST API: Endpoints and curl
Updated
An OpenAI-compatible endpoint is just HTTPS and JSON, so curl is enough to test it. This page walks through each call against a hosted text model, with the exact URLs, headers and bodies.
Key points
- Two endpoints cover everything: POST /v1/chat/completions and GET /v1/models.
- Auth is a Bearer header, and the model ID is uncensored.
- Streaming, tool calling and JSON mode use the same request fields as the OpenAI format.
- Limits are 8 concurrent requests and 300 per minute on a full key; over-limit calls return HTTP 429.

What an OpenAI compatible REST API gives you
An OpenAI compatible REST API accepts the same HTTP requests the OpenAI SDKs send, so any client that lets you change the base URL can talk to it. For this service the base URL is https://api.openaicompatibleapi.com/v1, the model ID is uncensored, and you authenticate with an Authorization: Bearer header that carries your API key. Two methods exist: POST /v1/chat/completions to generate text and GET /v1/models to list models.
That small surface is the whole point. There is no custom SDK to learn and no vendor-specific payload. If you have ever sent a chat request with curl, Postman, a Python script or a no-code tool, you already know the shape. What changes is where the request goes, which key it carries and which model answers it.
The model behind the endpoint is one open-weight model run by an independent provider, tuned to answer without content refusals for lawful adult use. It is not the official API of any model vendor and it is not a router across vendors. It handles text only: no images, audio, video, embeddings or fine-tuning. One hard limit applies to everything: no sexual content involving minors.
You will need a key before the examples work. New accounts can claim a trial key with one click after sign-up. It carries $0.50 of credit, lasts 7 days and needs no card. In the commands below the key lives in an environment variable so it never ends up in your shell history or your code.
export API_KEY="paste-your-key-here"
export BASE="https://api.openaicompatibleapi.com/v1"Check the connection with GET /v1/models
Before you send a prompt, confirm that the key and URL are right. The models call is cheap, has no body and fails loudly if something is off.
curl -s "$BASE/models" \
-H "Authorization: Bearer $API_KEY"
A healthy answer is a JSON object with a data array, and one entry in it has the ID uncensored. That is the string you will put in every request body. If you get a 401, the key is missing or mistyped; check that there are no stray quotes or line breaks in the variable. If the connection hangs or fails to resolve, look at the URL: the path must be /v1/models, so with the base above you should not repeat /v1 yourself.
That double /v1 is the most common mistake with this kind of endpoint. Some clients want the base URL with /v1 at the end, others add it on their own. When a request returns 404, print the final URL your client builds and compare it with the two paths in this article.
A first chat completion with curl
The chat endpoint takes a list of messages with roles (system, user, assistant) and returns the next assistant message.
curl -s "$BASE/chat/completions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [
{"role": "system", "content": "You are a concise technical assistant."},
{"role": "user", "content": "Explain what an HTTP 429 means in two sentences."}
],
"temperature": 0.7,
"max_tokens": 200
}'
The response is a JSON object. The text you want sits at choices[0].message.content, the reason generation stopped is in choices[0].finish_reason, and token counts are under usage. If you work in a shell, pipe the output through jq -r '.choices[0].message.content' to print only the answer.
Two details are easy to miss. First, max_tokens is optional. When you leave it out, the completion can use whatever is left of the 100,000-token window, which is shared between prompt and completion. Second, the response headers carry useful numbers: X-Request-Id for support questions, X-Balance-USD for your remaining credit, plus X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency for your limits. Add -i to curl to see them.
Request fields that are passed through
You do not need a special parameter list. These fields from the OpenAI format work as you would expect:
temperatureandtop_pcontrol randomness. Change one at a time; moving both makes it hard to see what helped.stoptakes a string or a list of strings that end generation early.seedmakes repeated runs more comparable when you are testing prompts.frequency_penaltyandpresence_penaltyreduce repetition in long outputs.streamswitches the response to server-sent events.tools,tool_choiceandresponse_formatenable tool calling and JSON mode, covered below.
The request body can be up to 8 MB. That is plenty for text, but if you paste whole documents into the prompt, remember that the token limit of 100,000 will bite before the byte limit does. Roughly speaking, a few hundred kilobytes of English text already fills the window.
Streaming responses over SSE
Set "stream": true and the server answers with text/event-stream. Each event is a line starting with data: followed by a JSON chunk, and the stream ends with usage information. In curl, add -N so the output is not buffered.
curl -N "$BASE/chat/completions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"stream": true,
"messages": [{"role": "user", "content": "Write a four-line poem about packet loss."}]
}'
Each chunk has a choices[0].delta object. The first chunk usually names the role, the following ones carry small pieces of content, and you concatenate them to rebuild the message. The official SDKs do this for you, which is why most people only touch raw SSE while debugging.
One operational point matters for load. A streamed request keeps its concurrency slot until the stream ends. If your app opens a stream for every user and never closes the abandoned ones, you will hit the concurrency cap of 8 on a full key long before you reach the request-per-minute cap. Close the connection when the user navigates away.
Tool calling and JSON mode
Tool calling follows the familiar two-step loop. You describe functions in tools, the model replies with tool_calls instead of text, your code runs the function, and you send the result back as a message with role: "tool".
curl -s "$BASE/chat/completions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "What is the status of order 1042?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_order_status",
"description": "Look up an order by its numeric ID",
"parameters": {
"type": "object",
"properties": {"order_id": {"type": "integer"}},
"required": ["order_id"]
}
}
}],
"tool_choice": "auto"
}'
When the model decides to call the function, choices[0].message.tool_calls holds the function name and a JSON string of arguments, plus an ID. Your second request repeats the conversation, appends the assistant message with the tool call, and adds a tool message whose tool_call_id matches. Parse the arguments defensively: they are model output, so validate them as you would any user input.
JSON mode is simpler. Add "response_format": {"type": "json_object"} and the reply is a JSON object. It is still good practice to say in the prompt which keys you expect, because JSON mode guarantees syntax, not your schema.
{
"model": "uncensored",
"response_format": {"type": "json_object"},
"messages": [
{"role": "user", "content": "Return JSON with keys title and tags (array) for a post about rate limits."}
]
}The same call from Python and Node
If you prefer an SDK, only two settings differ from a stock OpenAI setup: the base URL and the key. Everything else, including streaming iterators and tool helpers, behaves as before.
from openai import OpenAI
client = OpenAI(base_url="https://api.openaicompatibleapi.com/v1", api_key="paste-your-key-here")
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Give me three names for a build server."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.openaicompatibleapi.com/v1",
apiKey: process.env.API_KEY,
});
const res = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Summarize REST in one sentence." }],
});
console.log(res.choices[0].message.content);
For deeper client settings, such as environment variables used by common tools, see the API docs.
Rate limits, headers and handling 429
A full key allows 8 concurrent requests and 300 requests per minute. A trial key allows 2 concurrent and 60 per minute. Go over and you get HTTP 429. The error code tells you which limit you hit: rate_limited means too many requests per minute, concurrency means too many at once. On temporary overload the API also answers 429, with a Retry-After: 5 header.
A sensible client handles all three the same way: wait, then retry with a little jitter. Honor Retry-After when present. For concurrency, the better fix is a semaphore in your own code that caps in-flight calls at 8 (or 2 on a trial key), so you rarely see the error at all.
import time, random, httpx
def chat(payload, key, tries=5):
for attempt in range(tries):
r = httpx.post("https://api.openaicompatibleapi.com/v1/chat/completions",
headers={"Authorization": f"Bearer {key}"},
json=payload, timeout=120)
if r.status_code == 429:
wait = float(r.headers.get("Retry-After", 2 ** attempt))
time.sleep(wait + random.random())
continue
r.raise_for_status()
return r.json()
raise RuntimeError("still rate limited")
Billing is per token: $0.15 per 1M input tokens and $0.50 per 1M output tokens, from prepaid credit with no subscription. Failed or refused requests are not charged. Details and top-up options are on the pricing page. For a comparison of this setup with simply routing through a proxy, see the proxy article.
More guides
Questions and answers
Which endpoints does the API support?
Two: POST /v1/chat/completions for text generation and GET /v1/models for listing models. There are no image, audio, embedding or fine-tuning endpoints.
What model ID do I send in the request?
Use uncensored in the model field. It is the only model available, and GET /v1/models returns it.
Do I need an SDK to use it?
No. Plain HTTPS with a JSON body and a Bearer header works, which is why curl is enough for testing. The OpenAI SDKs also work once you change the base URL and key.
Why do I get a 429 error?
You exceeded 300 requests per minute (rate_limited), 8 simultaneous requests (concurrency), or the service is briefly overloaded. Wait for the Retry-After value and retry, and cap in-flight requests in your code.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.