# The /auto endpoint (/docs/proxy/routing/auto-endpoint)



`/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:

```text
https://proxy.tawaguard.com/<token>/auto/v1
```

The proxy picks the provider in this order:

1. The `x-tawa-upstream` header, if it is present.
2. 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 [#set-a-default-provider]

<Steps>
  <Step>
    ### Open the setting [#open-the-setting]

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

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

  <Step>
    ### Save [#save]

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

The default is reachable only through `/auto`. A request to
`/<token>/openai/v1/...` still goes to OpenAI, whatever the default is.

## Use it [#use-it]

With a default provider set, a client needs no header. Add the header to send a
request somewhere else.

<Tabs groupId="client" items="[&#x22;OpenAI SDK (Python)&#x22;, &#x22;OpenAI SDK (TypeScript)&#x22;, &#x22;Anthropic SDK (Python)&#x22;, &#x22;Anthropic 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"],
    )

    # 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"},
    )
    ```
  </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,
    });

    // 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" } },
    );
    ```
  </Tab>

  <Tab value="Anthropic SDK (Python)">
    The Anthropic SDK adds `/v1/messages` itself, so the base URL ends at `/auto`.

    ```python
    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)
    ```
  </Tab>

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

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

## What to know [#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](/docs/proxy/reference/routing-rules).
