EN ▾
Get API key

OpenAI-Compatible Endpoint for OpenRouter Clients

An openrouter openai compatible endpoint is just a base URL that speaks the OpenAI chat format, so swapping it for another one takes a few lines. Here are the exact values, the request shapes and the errors you may meet.

Updated

A single cable plugging a terminal into a glowing model cube, representing a swapped API endpoint

Key points

  • Base URL is https://api.openrouteralternativeapi.com/v1 and the model ID is uncensored.
  • Auth is a standard Bearer header; only POST /v1/chat/completions and GET /v1/models exist.
  • Streaming, tools and JSON mode work, but router-only fields are not supported.
  • On HTTP 429, read the error code to tell a rate limit from a concurrency limit.

The values you need

Any tool that lets you edit an OpenAI-style endpoint needs three values. Copy them from the table and nothing else changes in a typical setup.

SettingValue
Base URLhttps://api.openrouteralternativeapi.com/v1
API keyCreated on the API key page
Model IDuncensored
Auth headerAuthorization: Bearer YOUR_API_KEY
Chat routePOST /v1/chat/completions
Model list routeGET /v1/models

The base URL already ends with /v1. Most SDKs append /chat/completions themselves, so do not add it twice. Some tools ask for the full chat route instead; in that case use the base URL followed by /chat/completions.

What the endpoint is and is not

Behind the URL sits one open-weight model, run by an independent provider and tuned to answer without content refusals for lawful adult use. It is not a router, so a request never gets forwarded to a different vendor. It is also not the official API of any model maker. This matters for configuration: there is no list of model slugs to choose from, no provider preference field and no fallback chain. You send uncensored and you get that one model.

The service is text only. Image generation, audio, video, embeddings and fine-tuning are not offered, so a client that calls /v1/embeddings or an images route will fail on this base URL. Keep those calls pointed at whatever service you already use for them, and set the base URL per feature rather than globally if your application mixes several.

One more compatibility point concerns the model list. A client that calls GET /v1/models at startup, to fill a dropdown or to validate a setting, will get the one model back. That is expected. If your code checks that a configured model name appears in the list, set the name to uncensored and the check passes. If your application hard-codes a vendor model name somewhere deep in a config file, search the repository for it before the first run, because a leftover string is the most common reason a migrated app still fails after the URL has been changed.

First request, three ways

Start with a request from the terminal. It proves the key, the URL and the model ID before any framework is involved.

curl https://api.openrouteralternativeapi.com/v1/models   -H "Authorization: Bearer $API_KEY"

curl https://api.openrouteralternativeapi.com/v1/chat/completions   -H "Authorization: Bearer $API_KEY"   -H "Content-Type: application/json"   -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Reply with the word ready."}],
    "max_tokens": 10
  }'

The same call with the Python SDK. Notice that nothing besides base_url and api_key differs from stock OpenAI code.

from openai import OpenAI

client = OpenAI(
    base_url="https://api.openrouteralternativeapi.com/v1",
    api_key="YOUR_API_KEY",
)

r = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Reply with the word ready."}],
    max_tokens=10,
)
print(r.choices[0].message.content)
print(r.usage)

And with Node, reading the key from an environment variable:

import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.openrouteralternativeapi.com/v1",
  apiKey: process.env.API_KEY,
});

const r = await client.chat.completions.create({
  model: "uncensored",
  messages: [{ role: "user", content: "Reply with the word ready." }],
  max_tokens: 10,
});
console.log(r.choices[0].message.content);

Many tools read environment variables rather than constructor arguments. The official SDKs commonly honour OPENAI_BASE_URL and OPENAI_API_KEY, which lets you redirect an unmodified script. Check the documentation of your SDK version to confirm the names.

Streaming, tools and JSON mode

The features most clients depend on are present. Set stream: true to receive server-sent events; usage is reported at the end of the stream. Tool calling accepts tools and tool_choice, streams tool_calls deltas, and expects results back as messages with role: "tool". JSON mode is enabled with response_format: {"type":"json_object"}. The sampling fields temperature, top_p, stop, seed and the frequency and presence penalties are passed through.

A streaming example in Python:

stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Write three short taglines for a coffee cart."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

And JSON mode, which is worth pairing with an instruction in the prompt that names the keys you expect:

r = client.chat.completions.create(
    model="uncensored",
    messages=[
        {"role": "system", "content": "Return JSON with keys title and tags (array of strings)."},
        {"role": "user", "content": "Summarise: a guide to brewing cold coffee at home."},
    ],
    response_format={"type": "json_object"},
)
print(r.choices[0].message.content)

Always parse the result in a try block anyway. JSON mode raises the odds of valid output but your code should still handle a malformed reply, for example by retrying once.

Multi-turn chats and tool calls

The endpoint is stateless, like the OpenAI chat route. It does not remember earlier calls, so each request must carry the conversation you want the model to see. Keep a list of messages, append the assistant reply after each turn, and send the whole list again. Watch the total: the 100,000-token window covers prompt plus completion, and long histories are also what drives input cost.

history = [{"role": "system", "content": "You answer in two sentences."}]

def chat(text):
    history.append({"role": "user", "content": text})
    r = client.chat.completions.create(model="uncensored", messages=history)
    reply = r.choices[0].message.content
    history.append({"role": "assistant", "content": reply})
    return reply

For tool calling, describe your functions in tools, run whatever the model asks for, and send the output back as a role: "tool" message that carries the matching tool_call_id. A minimal definition looks like this:

tools = [{
    "type": "function",
    "function": {
        "name": "get_order_status",
        "description": "Look up an order by its number",
        "parameters": {
            "type": "object",
            "properties": {"order_id": {"type": "string"}},
            "required": ["order_id"],
        },
    },
}]

r = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Where is order 1042?"}],
    tools=tools,
    tool_choice="auto",
)
call = r.choices[0].message.tool_calls[0]
print(call.function.name, call.function.arguments)

Validate the arguments before running anything. The model proposes a call; your code decides whether it is safe to execute, especially when the function touches money, files or other people's data.

Fields to remove from OpenRouter-style requests

Clients written for a router often add extras to the request body or headers. Typical examples are provider ordering, model fallback arrays, routing preferences and attribution headers. This API does not use them. Unknown fields may be ignored or may cause an error, depending on the field, so strip them rather than rely on either outcome.

  • Replace any model slug that includes a vendor prefix with uncensored.
  • Drop fallback lists. If the single model is unavailable, handle it in your own retry logic.
  • Do not send image or audio content parts. The model reads text.
  • Keep the total request body under 8 MB.

The docs page shows the parameters that are supported, and it is the place to check when a field behaves differently from what your client expects.

Limits and the 429 responses

A full key allows 8 concurrent requests and 300 requests per minute; a trial key allows 2 and 60. Each response carries X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests and X-RateLimit-Limit-Concurrency. Log the request ID with every failure, because it is the first thing support will ask for.

There are three kinds of HTTP 429. The error code rate_limited means you exceeded requests per minute: slow down. The code concurrency means too many requests are in flight at once: queue them. A 429 with a Retry-After: 5 header means temporary overload: wait five seconds and try again. Remember that a streamed request keeps its concurrency slot until the stream ends, so a stalled client that never reads to the end will eat capacity.

import time
from openai import OpenAI, RateLimitError

client = OpenAI(
    base_url="https://api.openrouteralternativeapi.com/v1",
    api_key="YOUR_API_KEY",
    max_retries=0,
)

def ask(prompt, tries=4):
    for i in range(tries):
        try:
            r = client.chat.completions.create(
                model="uncensored",
                messages=[{"role": "user", "content": prompt}],
            )
            return r.choices[0].message.content
        except RateLimitError as e:
            wait = 5 if i == 0 else 5 * (i + 1)
            time.sleep(wait)
    raise RuntimeError("still rate limited")

Also set a semaphore of 8 or fewer around calls if you run workers in parallel. That is cheaper than learning the limit from errors. Add a little random jitter to the wait so that several workers that failed together do not all retry in the same second. If you see repeated 429 responses at low traffic, look for streams that are opened but never closed, or for a retry loop that fires without waiting, since either one can fill the available slots on its own.

Cost check before you point production at it

Pricing is $0.15 per 1M input tokens and $0.50 per 1M output tokens from prepaid credit. Take a request with 2,000 input tokens and 500 output tokens. Input costs 2,000 / 1,000,000 x $0.15 = $0.0003. Output costs 500 / 1,000,000 x $0.50 = $0.00025. The request costs $0.00055, so 1,000 such requests cost $0.55. Failed or refused requests are not charged. See the pricing page for top-up amounts and bonuses; the trial credit of $0.50 covers about 900 requests of that size (0.50 / 0.00055).

Questions and answers

What is the base URL for the OpenAI-compatible endpoint?

Use https://api.openrouteralternativeapi.com/v1 as the base URL and send your key as a Bearer token. The model ID is uncensored.

Which routes are available?

POST /v1/chat/completions for generation and GET /v1/models for the model list. There are no embeddings, image, audio or fine-tuning routes.

Do I need to change my code beyond the URL and key?

Usually only the model string. Remove router-specific fields such as provider preferences or fallback lists from request bodies.

Why do I get HTTP 429?

Check the error code. rate_limited means too many requests per minute, concurrency means too many at once, and a Retry-After: 5 header means temporary overload.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.