OpenRouter provider limits
Limit which hosting providers OpenRouter may use for an app. Allow a list, block a list, or require providers that do not collect or train on prompts. A client can narrow these limits but never widen them.
OpenRouter routes each request to one of many hosting providers. In the OpenRouter entry you can limit which ones are used. The proxy adds your limits to every request that goes through the entry, and a client can narrow them but never widen them.
The three limits
| Setting in the dashboard | What it does |
|---|---|
| Only allow these providers | Requests are routed only to the providers you list. Leave it empty to allow any. |
| Never use these providers | Requests are never routed to the providers you list. |
| Only providers that do not collect or train on prompts | Requests are routed only to providers that do not collect or train on prompts. |
Provider names are the names OpenRouter shows for a hosting provider, for
example DeepInfra or Parasail. A list can hold up to 32 names.
Set the limits
Open the OpenRouter entry
In the dashboard, open the app and go to App settings, then Allowed providers. Make sure OpenRouter is ticked.
Choose the limits
Under OpenRouter providers, fill in Only allow these providers, Never use these providers, or tick Only providers that do not collect or train on prompts. A name cannot be in both lists.
Save
A change reaches the proxy in about 20 seconds.
How limits combine with the request
A client can send its own provider field. The proxy rewrites it so your limits
can only tighten it.
| Limit | Result when the client sends its own provider field |
|---|---|
| Only allow | The two lists are intersected, ignoring case. If nothing is left, the proxy returns 400 with tawa_provider_not_allowed and nothing reaches OpenRouter. |
| Never use | Your list is added to the client's, and removed from any order the client sent. |
| No collection or training | data_collection is set to deny, even if the client sent allow. |
Anything else in provider | Kept as the client sent it. |
A provider field that is not an object returns 400 with
tawa_provider_policy_invalid.
The limits apply in Monitoring and in Blocking, and whatever the scan finds. Scanning sees the original request, and responses are not changed.
Example
The entry allows only DeepInfra and Parasail. The client narrows further to
DeepInfra:
import os
from openai import OpenAI
client = OpenAI(
base_url=f"https://proxy.tawaguard.com/{os.environ['TAWA_PROXY_TOKEN']}/openrouter/v1",
api_key=os.environ["OPENROUTER_API_KEY"],
)
reply = client.chat.completions.create(
model="meta-llama/llama-3.3-70b-instruct",
messages=[{"role": "user", "content": "Hello"}],
extra_body={"provider": {"only": ["DeepInfra"]}},
)
print(reply.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: `https://proxy.tawaguard.com/${process.env.TAWA_PROXY_TOKEN}/openrouter/v1`,
apiKey: process.env.OPENROUTER_API_KEY,
});
const body = {
model: "meta-llama/llama-3.3-70b-instruct",
messages: [{ role: "user" as const, content: "Hello" }],
provider: { only: ["DeepInfra"] },
};
const reply = await client.chat.completions.create(body);
console.log(reply.choices[0].message.content);curl "https://proxy.tawaguard.com/$TAWA_PROXY_TOKEN/openrouter/v1/chat/completions" \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "meta-llama/llama-3.3-70b-instruct",
"messages": [{"role": "user", "content": "Hello"}],
"provider": {"only": ["DeepInfra"]}
}'If the client had asked for {"only": ["Cloudflare"]} instead, nothing would be
left after the intersection and the proxy would return tawa_provider_not_allowed.
What to know
- Provider limits can be narrowed by a client but not widened.
- An entry with limits has to read the request body, so the body must be uncompressed JSON within the body limit. Otherwise the proxy returns
400withtawa_provider_policy_unenforceable. Do not send aContent-Encodingheader on these requests. - An entry without limits forwards the body byte for byte.
- Limits apply to an OpenAI-format entry. A custom OpenAI-format endpoint that routes to several providers can carry them too. See Custom endpoints.
- Limits restrict which OpenRouter hosting providers receive the request. They do not change the model. See OpenRouter.
- Check an error against Error codes.
OpenRouter
Scan OpenRouter traffic with Tawa Guard. One entry reaches hundreds of models; switch models by changing the model field. Examples for the OpenAI SDK and curl, and what OpenRouter routing means for the model you get.
Custom endpoints
Add your own endpoint to an app's allowed providers, such as an Azure OpenAI deployment or a self-hosted server. HTTPS and public addresses only, in OpenAI or Anthropic format.