# OpenRouter (/docs/proxy/routing/openrouter)



[OpenRouter](https://openrouter.ai) gives you access to hundreds of models
through one API and one key. Add it to your app's allowed providers and the
proxy scans every OpenRouter request the same way it scans OpenAI or Anthropic
traffic.

The proxy tested 175 OpenRouter models, and 172 passed every check. See
[Verified models](/docs/proxy/verified-models) for the full table.

## Set it up [#set-it-up]

<Steps>
  <Step>
    ### Allow OpenRouter [#allow-openrouter]

    In the dashboard, open the app and go to **App settings**, then **Allowed
    providers**. Tick **OpenRouter** and save. A change reaches the proxy in about
    20 seconds. Optionally set
    [provider limits](/docs/proxy/routing/openrouter-provider-limits) on the entry.
  </Step>

  <Step>
    ### Point your client at it [#point-your-client-at-it]

    Use the OpenRouter name in the URL, or the `/auto` endpoint with the
    `x-tawa-upstream` header. OpenRouter uses the OpenAI format, so use the OpenAI
    SDK or any OpenAI-compatible client, and send your OpenRouter key.

    <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="openai/gpt-4o-mini",
            messages=[{"role": "user", "content": "Hello"}],
        )
        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 reply = await client.chat.completions.create({
          model: "openai/gpt-4o-mini",
          messages: [{ role: "user", content: "Hello" }],
        });
        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": "openai/gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}]}'
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>

<Callout type="info" title="Using the Anthropic SDK">
  OpenRouter is an OpenAI-format entry, so it serves `/chat/completions` and
  `/responses`. A request to `/v1/messages` through it returns `404` with
  `tawa_path_not_proxied`. Call Claude models through OpenRouter with the OpenAI
  SDK and a model name such as `anthropic/claude-haiku-4.5`.
</Callout>

## Switch models on the fly [#switch-models-on-the-fly]

You change models by changing the `model` field. Nothing else in your setup
moves: same token, same URL, same key. Every request is scanned the same way.

<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']}/auto/v1",
        api_key=os.environ["OPENROUTER_API_KEY"],
        default_headers={"x-tawa-upstream": "openrouter"},
    )

    for model in ["openai/gpt-4o-mini", "meta-llama/llama-3.3-70b-instruct"]:
        reply = client.chat.completions.create(
            model=model,
            messages=[{"role": "user", "content": "Hello"}],
        )
        print(model, "->", 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}/auto/v1`,
      apiKey: process.env.OPENROUTER_API_KEY,
      defaultHeaders: { "x-tawa-upstream": "openrouter" },
    });

    for (const model of ["openai/gpt-4o-mini", "meta-llama/llama-3.3-70b-instruct"]) {
      const reply = await client.chat.completions.create({
        model,
        messages: [{ role: "user", content: "Hello" }],
      });
      console.log(model, "->", reply.choices[0].message.content);
    }
    ```
  </Tab>

  <Tab value="curl">
    ```bash
    for model in openai/gpt-4o-mini meta-llama/llama-3.3-70b-instruct; do
      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\": \"$model\", \"messages\": [{\"role\": \"user\", \"content\": \"Hello\"}]}"
    done
    ```
  </Tab>
</Tabs>

## Which model do you get? [#which-model-do-you-get]

The proxy never changes the model you ask for. If you ask for a model, that is
the model OpenRouter is asked to use. The proxy forwards your request body
byte for byte, so any OpenRouter model name works.

<Callout type="warn" title="Routing models and fallback lists let OpenRouter pick">
  These are choices you make in the request, and the proxy leaves them alone:
  an OpenRouter routing model such as `openrouter/auto` or `openrouter/free`,
  or your own fallback list of models. OpenRouter then picks the model, so the
  model that answered can differ from the one you named first.
</Callout>

If you need to know which model answered, read the `model` field of the
response.

## Other models, other providers [#other-models-other-providers]

To send some requests to OpenAI or Anthropic directly and others to OpenRouter,
allow all of them and use a [name in the URL or the `x-tawa-upstream` header](/docs/proxy/routing/per-request).
Send each provider its own key.

## What to know [#what-to-know]

* Your OpenRouter key passes straight through to OpenRouter. Tawa Guard does not store it.
* OpenRouter routes each request to one of several hosting providers. You can limit which ones in [provider limits](/docs/proxy/routing/openrouter-provider-limits).
* A model can reject a request for its own reasons, for example a model that requires audio input. Those errors come from the provider, in the provider's format.
* Check your model in [Verified models](/docs/proxy/verified-models) before you rely on it.
