Tawa docs

Routing rules

The exact rules the Tawa Guard proxy uses to turn a request into a provider call: URL forms, header precedence, entry names, formats and address checks.

URL forms

FormURL
Provider by namehttps://proxy.tawaguard.com/<token>/<name>/v1/...
OpenAI Chat Completions and Responseshttps://proxy.tawaguard.com/<token>/openai/v1
Anthropic Messageshttps://proxy.tawaguard.com/<token>/anthropic
One URL, provider by header or defaulthttps://proxy.tawaguard.com/<token>/auto/v1
Token in a headerhttps://proxy.tawaguard.com/<name>/v1 with x-tawa-proxy-token

<token> is a proxy token: tgp_ followed by 64 letters. The proxy removes the token and the name from the path and forwards the rest to the provider unchanged.

Which provider a request uses

In order:

  1. The x-tawa-upstream header.
  2. The name in the URL, for example /<token>/openrouter/v1/....
  3. The app's Default provider, reachable only through /auto.

Nothing in the request body, the model name or the key is consulted. A name that is missing or is not on the app's list returns 400 with tawa_upstream_unresolved.

The /auto path takes the API format from the request path. The provider that is chosen must use that format.

Entries

Each allowed provider is an entry.

FieldRule
Name1 to 32 characters of a-z, 0-9 and -. Built-in names and auto are reserved.
Base URLHTTPS. No credentials, query or fragment. May carry a path prefix, for example https://openrouter.ai/api.
Formatopenai serves /chat/completions and /responses. anthropic serves /messages.
Key headerauthorization, x-api-key or api-key. The proxy forwards your own key header as sent.
Provider limitsOpenAI-format entries only. See OpenRouter provider limits.

An app can have up to 20 entries. With no list saved, the entries are openai (api.openai.com) and anthropic (api.anthropic.com). Once a list is saved, the allowlist is exactly the entries on it.

A request whose path format does not match the entry's format returns 404 with tawa_path_not_proxied.

Address checks for custom endpoints

A custom base URL is refused when it is not HTTPS, has credentials, a query or a fragment, or its host is localhost or an address in a private, loopback, link-local, shared-address or metadata range. When a request arrives, the proxy resolves the host and refuses the request with 502 and tawa_upstream_blocked if any address it resolves to is in those ranges. Redirects are never followed. The built-in entries skip the address check.

Headers

  • x-tawa-upstream and x-tawa-proxy-token are removed before the request goes to the provider.
  • Headers that start with x-tawa- or x-forwarded-, x-real-ip and Forwarded are removed too.
  • Your provider key headers (Authorization, x-api-key, api-key, openai-organization, openai-project) are forwarded and are not stored or logged.
  • Query strings are forwarded.

Timing

A change to an app's allowed providers reaches the proxy in about 20 seconds.

On this page