From OpenRouter
Move OpenRouter traffic to plaingateway: base URL, key, model ids, headers, routing fields, cost, errors and what is not supported.
plaingateway uses the OpenRouter API: the same paths, request fields, response shapes, model ids and errors. Most clients need two changes, the base URL and the key. plaingateway is the free OpenRouter alternative: every token costs the provider's list price, with 0% platform fee, no markup and no subscription, and it is free with your own keys. Tokens are never free. Both bill inference at the provider's list price. The difference is the fee. In OpenRouter's words, "OpenRouter charges a 5.5% ($0.80 minimum) fee when you purchase credits" (openrouter.ai/docs/faq, read 2026-11-11). plaingateway charges 0%. Each person you invite gives you 1% bonus credit when you add money, once they have paid $20 in total, up to 20%: pay $100, get up to $120 of credit. The person you invite gets 5% bonus credit on their first top-up. See Bonus and referral credit. The side-by-side table, with sources and read dates, is at plaingateway vs OpenRouter.
Base URL and key
| Setting | OpenRouter | plaingateway |
|---|---|---|
| OpenAI-compatible base URL | https://openrouter.ai/api/v1 |
https://api.plaingateway.com/api/v1 |
| Anthropic SDK and Claude Code base URL | https://api.plaingateway.com/api |
|
| Key | sk-or-v1-... |
sk-pg-v1-... |
A plaingateway key is sk-pg-v1- followed by 64 hex characters. Create one at plaingateway.com/settings/keys.
Send it as Authorization: Bearer <key>. X-Api-Key: <key> also works, which is how the Anthropic SDK and Claude Code send it.
The site host, plaingateway.com, serves no API.
Model ids
Model ids are the same as on OpenRouter, with the author prefix: openai/gpt-5.6-luna, deepseek/deepseek-v4-flash. Today only openai/ and deepseek/ models answer.
plaingateway serves fewer models than OpenRouter lists. Check each id you use in GET /models or on plaingateway.com/models. An id the gateway does not route returns 400.
Two variants work: :floor (cheapest host first) and :nitro (highest throughput first); see Model variants. Any other suffix, such as :free, :thinking, :extended or :online, returns 400 unless the full id is itself a routed model.
The models array works as on OpenRouter: the gateway tries each model in turn after model. See Model fallbacks.
Headers
Request headers the gateway reads
| Header | What the gateway does with it |
|---|---|
Authorization: Bearer sk-pg-v1-... |
Your key. |
X-Api-Key: sk-pg-v1-... |
Your key, when there is no Authorization header. |
HTTP-Referer |
Your app's URL, for app attribution. |
X-OpenRouter-Title or X-Title |
Your app's name, for app attribution. |
Anthropic-Version, Anthropic-Beta |
Passed to Anthropic hosts on /messages. Without Anthropic-Version the gateway sends 2023-06-01. |
The gateway also stores User-Agent with the request and returns it in GET /generation. Any other request header is not read. Only the Anthropic headers, and the attribution headers on a host that speaks the OpenRouter API, reach the host.
Response headers
| Header | Meaning |
|---|---|
X-PG-Host |
The host that served the request, for example DeepInfra, or none. |
X-PG-Cost-USD |
The charge in USD, on a non-streamed answer. |
X-Generation-Id |
The generation id. Pass it to GET /generation. |
X-PG-Request-Id |
The same value as X-Generation-Id. |
Retry-After |
Passed through when the host sent it, usually on 429. |
X-PG-Host, X-PG-Cost-USD and X-PG-Request-Id are plaingateway only. The full list is on Headers.
Provider routing
Each model has one pinned host. Without provider.order, provider.sort or a variant, the gateway tries it first, so the host's prompt cache keeps working. On a connection error, a timeout, a 5xx, a 429 or a 408, the request moves to the model's next listed host. Another 4xx, such as a context length error, comes back to you.
The provider object works as on OpenRouter, with these fields. A provider name is a host name as X-PG-Host shows it, for example DeepInfra, Novita, OpenAI or Anthropic.
| OpenRouter field | On plaingateway |
|---|---|
order |
Tries these hosts first, in this order, then the other eligible hosts. |
only |
Allows only these hosts. |
ignore |
Never uses these hosts. |
sort |
Orders by price, throughput or latency, from each host's configured figures. |
allow_fallbacks |
false tries only the hosts named in order, or only the first host without order. |
data_collection |
deny keeps only hosts marked as never keeping data. |
zdr |
true keeps only hosts marked as keeping no prompts or outputs. |
quantizations |
Keeps hosts running these quantizations, such as fp8. |
max_price |
Highest prompt and completion price, in USD per 1M tokens. |
Any other provider field, such as require_parameters, returns 400. So does a field in max_price other than prompt and completion, or a bad sort value.
Fallbacks can also be turned off for the whole account: turn Allow fallbacks off at /settings/preferences. Each model then gets one host, or only the hosts named in provider.order, and that host's error comes back to you. Models in the models array are still tried in turn. A request that sets provider.allow_fallbacks overrides the setting.
Today no routed host is marked as keeping no data, so provider.zdr: true or provider.data_collection: "deny" leaves no host and returns 404.
The details are on Provider routing.
Usage and cost
Every answer carries usage, whether or not you send usage: {"include": true}. plaingateway adds usage.cost, the charge in USD.
A non-streamed answer also has the X-PG-Cost-USD header. GET /generation returns the cost and token counts a moment after the request ends.
The charge is the token counts the host reported, times the price per token. Prices are the provider's list price, with 0% platform fee and no markup. Earned bonus credit is added to your balance when you add money, never taken off the token price.
Before a request starts, the gateway reserves its largest possible cost from your balance, sized from max_tokens and the prompt. When funds are short it reserves an eighth of what is left and lowers the answer's limit to fit, shown in the X-PG-Output-Cap header. When the request ends, the real cost replaces the reserve.
usage.is_byok is true when one of your own provider keys served the request.
Open Logs in a workspace to see each request and its cost (kept for seven days). See Usage accounting.
Streaming
Streams are server-sent events. Chat and completions streams end with data: [DONE], as on OpenRouter. A /messages stream on an Anthropic host ends with message_stop.
The cost of a stream is in the final usage chunk: read usage.cost there. A stream has no X-PG-Cost-USD header, because headers are sent before the cost is known. On a stream that waits over 15 seconds for its host, X-PG-Host reads none, because the headers went out with the first : PLAINGATEWAY PROCESSING line.
While the host has not answered yet, the gateway sends : PLAINGATEWAY PROCESSING comment lines every 15 seconds. Ignore lines that start with :.
A failure after the stream started arrives as a last event with an error object. Its code is 408 for a timeout, 402 or 503 when the balance hold fails before a fallback, and 502 otherwise. While the gateway has sent only : PLAINGATEWAY PROCESSING lines, it can still move to another host. Once a host's output has started, it never does.
Prompt caching
Host pinning sends a model's requests to the same first host each time, so a cache built on that host is used again.
A cached input token is billed at the host's lower cache read price. Both cache prices are in GET /models as input_cache_read and input_cache_write.
On an Anthropic host, mark the part to cache with cache_control, on /messages or in chat completions content parts. On /messages, usage.cache_read_input_tokens and usage.cache_creation_input_tokens count the tokens.
OpenAI hosts cache long prompts on their own. usage.prompt_tokens_details.cached_tokens counts the cached input tokens.
See Prompt caching.
Errors
Errors keep OpenRouter's shape. error.code is the HTTP status:
{"error": {"message": "No endpoints found matching your provider.only list", "code": 404, "metadata": {"failed_routing_step": "Filter by Only"}}}/messages uses Anthropic's error shape instead.
| Status | Cause |
|---|---|
| 400 | Invalid JSON, an unknown model id, an unsupported variant, a bad provider object, or plugins or transforms set |
| 401 | No key, or a key that is unknown, disabled, expired or revoked |
| 402 | The balance cannot cover the request, or the key reached its spend limit |
| 404 | Unknown path or generation id, or no host left after the provider filters |
| 408 | The host sent no answer in time |
| 413 | The request body is over 32 MiB |
| 429 | The last host tried rate limited the request |
| 500 | The details for the model could not be read |
| 502 | The host returned an error, or a response that was cut off or unreadable |
| 503 | The gateway cannot check keys, the balance or usage for a moment |
An error answered before the host produced output is not charged. A host's own 4xx, such as a context length error, keeps its status, with the host's body in metadata.raw. A host's 401 or 403 means the host refused the gateway's credentials, so you get 502. See Errors.
Rate limits
The gateway sets no request rate limit of its own. The provider's rate limits pass through.
When a host answers 429, the gateway tries the model's next eligible host. It also moves on after a timeout or a 5xx. You get 429 only when the last host tried also refused, with Retry-After when that host sent it.
A model with one host has no other host to try. Add fallback models in models to spread the load.
The balance is the other limit: each request reserves its largest possible cost, or an eighth of what is left with a lower answer limit, so many large requests at once get shorter answers, then 402 once what is left cannot pay for a prompt and a 4,096 token answer. A lower max_tokens reserves less.
The rate_limit field in GET /auth/key is deprecated and means nothing. See Rate limits.
What is not supported
pluginsandtransforms. Any value other thannullreturns 400. That includes web search and the:onlinesuffix.- Models with no token charge. Every token costs the provider's list price, and the
:freesuffix returns 400. On your own provider keys plaingateway charges 0% platform fee, and your provider bills you for the tokens. - Variants other than
:floorand:nitro. providerfields other than the nine in the table above.- Models the gateway does not route. Check plaingateway.com/models first.
- On
/responseswith a model that is not on an OpenAI host,previous_response_idand tools other than function tools return 400.
The route field is accepted and not read. On a host that speaks the same API as the request, a field the gateway does not read, such as temperature, goes to the host unchanged. A translated request, such as /chat/completions to an Anthropic host, carries only the fields the translation maps, so a field such as seed is dropped.
Checklist
- Create a key at plaingateway.com/settings/keys and top up, or add your own provider keys.
- Change the base URL to
https://api.plaingateway.com/api/v1, orhttps://api.plaingateway.com/apifor the Anthropic SDK. - Replace the OpenRouter key with the plaingateway key.
- Check that each model id you use is in GET /models.
- Remove
:free,:onlineand any variant other than:floorand:nitro. - Remove
pluginsandtransforms, or set them tonull. - Keep only the nine supported
providerfields. - Read the cost from
usage.cost, or from the final usage chunk on a stream. - Send one request and check
X-PG-HostandX-PG-Cost-USDon the answer.
Both bill tokens at the provider's list price. To see what you save, paste your usage into /migrate. It shows the credit your tokens need and the fee OpenRouter charges to buy that credit; plaingateway charges 0%.
SDK examples
OpenAI Python
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.plaingateway.com/api/v1", api_key=os.environ["PLAINGATEWAY_API_KEY"])
answer = client.chat.completions.create(model="openai/gpt-5.6-luna", messages=[{"role": "user", "content": "Say hello in five words."}])
print(answer.choices[0].message.content, answer.usage)OpenAI JavaScript
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.plaingateway.com/api/v1", apiKey: process.env.PLAINGATEWAY_API_KEY });
const answer = await client.chat.completions.create({ model: "openai/gpt-5.6-luna", messages: [{ role: "user", content: "Say hello in five words." }] });
console.log(answer.choices[0].message.content, answer.usage);Anthropic SDK
import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.plaingateway.com/api", api_key=os.environ["PLAINGATEWAY_API_KEY"])
message = client.messages.create(model="openai/gpt-5.6-luna", max_tokens=64, messages=[{"role": "user", "content": "Say hello in five words."}])
print(message.content[0].text)The SDK appends /v1/messages. A model on a non-Anthropic host is translated to and from chat completions; see Messages.
curl
curl -i https://api.plaingateway.com/api/v1/chat/completions \
-H "Authorization: Bearer $PLAINGATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-5.6-luna", "messages": [{"role": "user", "content": "Say hello in five words."}], "provider": {"allow_fallbacks": false}}'