# OpenRouter provider limits (/docs/proxy/routing/openrouter-provider-limits)



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 [#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 [#set-the-limits]

<Steps>
  <Step>
    ### Open the OpenRouter entry [#open-the-openrouter-entry]

    In the dashboard, open the app and go to **App settings**, then **Allowed
    providers**. Make sure **OpenRouter** is ticked.
  </Step>

  <Step>
    ### Choose the limits [#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.
  </Step>

  <Step>
    ### Save [#save]

    A change reaches the proxy in about 20 seconds.
  </Step>
</Steps>

## How limits combine with the request [#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 [#example]

The entry allows only `DeepInfra` and `Parasail`. The client narrows further to
`DeepInfra`:

<Tabs groupId="client" items="[&#x22;OpenAI SDK (Python)&#x22;, &#x22;OpenAI SDK (TypeScript)&#x22;, &#x22;curl&#x22;]">
  <Tab value="OpenAI SDK (Python)">
    ```python
    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)
    ```
  </Tab>

  <Tab value="OpenAI SDK (TypeScript)">
    ```ts
    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);
    ```
  </Tab>

  <Tab value="curl">
    ```bash
    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"]}
      }'
    ```
  </Tab>
</Tabs>

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 [#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 `400` with `tawa_provider_policy_unenforceable`. Do not send a `Content-Encoding` header 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](/docs/proxy/routing/custom-endpoints).
* Limits restrict which OpenRouter hosting providers receive the request. They do not change the model. See [OpenRouter](/docs/proxy/routing/openrouter#which-model-do-you-get).
* Check an error against [Error codes](/docs/proxy/reference/error-codes).
