Tawa docs

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.

OpenRouter 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 for the full table.

Set it up

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 on the entry.

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.

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)
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);
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"}]}'

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.

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.

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)
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);
}
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

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.

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.

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

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. Send each provider its own key.

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.
  • 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 before you rely on it.

On this page