Key points
- OpenRouter is a router: one key, many models, chosen by a model name in each request.
- The setup is account, credit, key and a first request with an OpenAI client.
- Routing adds flexibility and also moving parts such as changing model lists and per-model limits.
- If you need one uncensored model, a direct endpoint needs only a new base URL and key.
What OpenRouter is and what it does
If you are searching for how to use OpenRouter, start with the idea behind it. OpenRouter is a routing service. You send a request to one address with one key, and the request is forwarded to a model hosted by one of several providers. The model is picked by the model field in your request, using names in a vendor/model form.
The practical benefit is that you do not open an account with each provider. You top up one balance, keep one key in your secrets store, and change the model name when you want to compare results. The practical cost is that you depend on a layer between you and the model: the list of models changes, providers behind a name can differ, and each model can have its own limits.
The interface follows the OpenAI chat completions format, which is why most existing code works with it. Anything that speaks that format can be pointed at a router, a direct provider, or a self-hosted server by changing two values: the base URL and the key.
Step by step: from account to first request
The flow is the same for most routers and gateways. Check the OpenRouter site for the current screens, since dashboards change, but the order stays the same.
- Create an account. Sign up with the method the site offers and confirm your email if asked.
- Add credit. Paid models draw from a prepaid balance. Some models are marked as free, and those come with tighter limits than paid ones.
- Create a key. Generate it in the keys section, copy it once, and store it in an environment variable. Never paste it into client-side code or a public repository.
- Pick a model name. Copy the exact identifier from the model page. A typo gives a not-found error, not a fallback.
- Send a request. Use the OpenAI SDK with the router base URL, or plain HTTP.
On the OpenRouter side the base URL is https://openrouter.ai/api/v1. Its docs also describe optional attribution headers that identify your app; they are not required for a request to work.
A first request with the OpenAI SDK
The code below shows the pattern. It is written against our endpoint so that you can copy it as it is, and it shows exactly which two values you change when you move between any OpenAI-compatible services.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.openrouteruncensored.top/v1",
api_key=os.environ["API_KEY"],
)
resp = client.chat.completions.create(
model="uncensored",
messages=[
{"role": "system", "content": "You are a concise technical assistant."},
{"role": "user", "content": "Explain what a context window is in two sentences."},
],
temperature=0.7,
)
print(resp.choices[0].message.content)
print(resp.usage)
The same request with curl is useful for testing a key before you write any application code:
curl https://api.openrouteruncensored.top/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Say hello in five words."}]
}'
To see which model IDs an endpoint accepts, call GET /v1/models with the same header. On a router that list is long. On our endpoint it contains the single ID uncensored.
Choosing models and understanding routing
One name, several possible providers
On a router, a model name can be served by more than one provider. Prices, speed and uptime can differ between them, and the router may choose among them for you. That is useful when one provider is down, and it is a reason to read the router docs on provider selection before you depend on consistent behaviour, for example identical output length or the same context limit on every request.
Free and paid variants
Some model names have a free variant. Free variants are meant for trying things out and carry stricter limits than paid ones. If your script works in a test and then fails in a loop, the limit is the first thing to check. For open-weight models served behind an OpenAI-style API, see our note on the uncensored Qwen API.
What to log
Whatever endpoint you use, log the model name, the HTTP status, the request ID from the response headers and the token counts from usage. Those four fields settle most arguments about cost and about whether a failure was yours or the provider's.
Keys, budgets and safe handling
A key is a password that spends money. Treat it like one. Keep it in an environment variable or a secrets manager, load it at process start and never commit it. If you build a browser app, do not call the API from the browser with your key inside the page, because anyone can read it in the network tab. Put a small server in between that holds the key and forwards the calls you allow.
Use a separate key for each project or environment. When a key leaks, you revoke one and the others keep working. It also makes the usage list readable: if the staging key spends more than production, you notice the same day.
Set a ceiling before you scale
Every pay-as-you-go service rewards a small amount of arithmetic done in advance. Multiply the expected input tokens by the input price and the expected output tokens by the output price, then add a margin for retries. A system prompt of 800 tokens sent with every call is easy to forget, and it is billed every time. On a service priced at $0.15 per 1M input tokens, 10,000 calls with that prompt alone use 8,000,000 input tokens, which is $1.20. Short, stable system prompts keep that figure small.
Set a budget alert in the dashboard if the service has one, and add your own check in code that stops a loop after a fixed number of calls. A runaway loop is the most common way a test turns into a surprise bill.
When a direct endpoint is the simpler choice
A router makes sense when you want to compare many models, or you need one bill for a mixed set of them. It makes less sense when you already know the model you need. In that case a direct endpoint removes a layer: there is one model, one set of limits and one price list.
Our service is built for that second case. It is a hosted, OpenAI-compatible API with a single open-weight model tuned to answer without content refusals for lawful adult use. It is run by an independent provider and is not the official API of any model vendor, and it is not a router. It does text only: no images, audio, embeddings or fine-tuning. The one hard limit is that sexual content involving minors is never allowed.
The numbers are short enough to list. Context is 100,000 tokens for prompt plus completion. A full key allows 8 concurrent requests and 300 requests per minute. Streaming, tool calling and JSON mode are supported. The price is $0.15 per 1M input tokens and $0.50 per 1M output tokens, billed from prepaid credit, and failed or refused requests are not charged. The pricing page has the top-up bonuses, and the docs show how to reuse client code written for a router.
Moving code between a router and a direct endpoint
If your project already runs on a router, switching is a configuration change, not a rewrite. Keep the base URL and model name in environment variables from the start so that the change never touches your logic.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: process.env.LLM_BASE_URL ?? "https://api.openrouteruncensored.top/v1",
apiKey: process.env.LLM_API_KEY,
});
const stream = await client.chat.completions.create({
model: process.env.LLM_MODEL ?? "uncensored",
messages: [{ role: "user", content: "Draft a two-line product update." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
Three differences are worth checking after the switch. First, the model name: a router name such as vendor/model must become uncensored. Second, any router-only request fields in your code, such as provider preferences, should be removed because a direct endpoint has nothing to apply them to. Third, retry logic: a streamed request holds its concurrency slot until the stream ends, so a stuck stream counts against your limit of 8.
New users can claim $0.50 of trial credit with one click on the API key page after sign-up. It lasts 7 days, needs no card and is limited to one per person. At about 1,000 input and 500 output tokens per call, that is $0.00015 plus $0.00025, or $0.0004 per call, so the trial covers roughly 1,250 test calls. You can get a key on the API key page.
