The /auto endpoint
Use one base URL, /auto/v1, for every allowed provider. The x-tawa-upstream header picks the provider and the app's default provider fills in when the header is absent.
/auto is a single base URL that serves every provider on the app's list. The
proxy chooses the provider for each request instead of the URL:
https://proxy.tawaguard.com/<token>/auto/v1The proxy picks the provider in this order:
- The
x-tawa-upstreamheader, if it is present. - The app's Default provider.
If neither names an allowed provider, the proxy returns 400 with the code
tawa_upstream_unresolved and sends nothing to a provider.
auto takes the API format from the request path: /chat/completions and
/responses are OpenAI format, /messages is Anthropic format. The provider
that is chosen must use the same format as the path.
Set a default provider
Open the setting
In the dashboard, open the app and go to App settings, then Allowed providers.
Choose the default
Under Default provider, choose one of the providers you have allowed. It is used when a request does not name one. Leave it empty to require a name on every request.
Save
A change reaches the proxy in about 20 seconds.
The default is reachable only through /auto. A request to
/<token>/openai/v1/... still goes to OpenAI, whatever the default is.
Use it
With a default provider set, a client needs no header. Add the header to send a request somewhere else.
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"],
)
# No header: the app's default provider is used.
client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)
# With the header: this request goes to the provider it names.
# Send that provider's key.
client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
extra_headers={"x-tawa-upstream": "openai"},
)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,
});
// No header: the app's default provider is used.
await client.chat.completions.create({
model: "openai/gpt-4o-mini",
messages: [{ role: "user", content: "Hello" }],
});
// With the header: this request goes to the provider it names.
// Send that provider's key.
await client.chat.completions.create(
{ model: "gpt-4o-mini", messages: [{ role: "user", content: "Hello" }] },
{ headers: { "x-tawa-upstream": "openai" } },
);The Anthropic SDK adds /v1/messages itself, so the base URL ends at /auto.
import os
from anthropic import Anthropic
client = Anthropic(
base_url=f"https://proxy.tawaguard.com/{os.environ['TAWA_PROXY_TOKEN']}/auto",
api_key=os.environ["ANTHROPIC_API_KEY"],
default_headers={"x-tawa-upstream": "anthropic"},
)
reply = client.messages.create(
model="claude-haiku-4-5",
max_tokens=256,
messages=[{"role": "user", "content": "Hello"}],
)
print(reply.content[0].text)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: `https://proxy.tawaguard.com/${process.env.TAWA_PROXY_TOKEN}/auto`,
apiKey: process.env.ANTHROPIC_API_KEY,
defaultHeaders: { "x-tawa-upstream": "anthropic" },
});
const reply = await client.messages.create({
model: "claude-haiku-4-5",
max_tokens: 256,
messages: [{ role: "user", content: "Hello" }],
});
console.log(reply.content[0]);# Uses the app's default provider.
curl "https://proxy.tawaguard.com/$TAWA_PROXY_TOKEN/auto/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"}]}'
# Names the provider with the header.
curl "https://proxy.tawaguard.com/$TAWA_PROXY_TOKEN/auto/v1/chat/completions" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "x-tawa-upstream: openai" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}]}'What to know
- The default provider is your choice for the app. Requests without a header use it, so pick one whose key your clients send.
- The proxy never reads the model name to choose a provider, and never changes the model.
- The proxy does not look at your key. Send the key that belongs to the provider the request resolves to.
Reference: Routing rules.
Choose a provider per request
Pick the provider for each request by naming it in the proxy URL or in the x-tawa-upstream header. Rules, precedence and examples for the OpenAI SDK, Anthropic SDK and curl.
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.