# Custom endpoints (/docs/proxy/routing/custom-endpoints)



If a provider is not in the [built-in list](/docs/proxy/routing/allowed-providers),
add it as your own endpoint. Typical cases are an Azure OpenAI deployment and a
self-hosted server that speaks the OpenAI or Anthropic API. An app can have up
to 20 entries, built-in and custom together.

## Add an endpoint [#add-an-endpoint]

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

    In the dashboard, open the app and go to **App settings**, then **Allowed
    providers**. Under **Your own endpoints**, choose **Add an endpoint**.
  </Step>

  <Step>
    ### Fill in the endpoint [#fill-in-the-endpoint]

    | Field          | What to enter                                                                                                                                                            |
    | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
    | **Name**       | The name you will use in the proxy URL or in `x-tawa-upstream`. Lowercase letters, numbers and hyphens, up to 32 characters. The built-in names and `auto` are reserved. |
    | **Base URL**   | The provider's base URL, for example `https://my-resource.openai.azure.com`. HTTPS only, on a public host name. It can include a path prefix.                            |
    | **Format**     | **OpenAI** for Chat Completions and Responses, or **Anthropic** for Messages.                                                                                            |
    | **Key header** | The header your provider expects the key in: `authorization`, `x-api-key` or `api-key`.                                                                                  |

    For an OpenAI-format endpoint that routes a model to several providers, you can
    also set provider limits. See [OpenRouter provider limits](/docs/proxy/routing/openrouter-provider-limits).
  </Step>

  <Step>
    ### Save the card [#save-the-card]

    Nothing changes until you save the **Allowed providers** card. A change reaches
    the proxy in about 20 seconds.
  </Step>
</Steps>

## How requests reach it [#how-requests-reach-it]

The proxy removes the token and the endpoint name from the path, then appends
the rest to your base URL. The query string is forwarded too, so an
`api-version` parameter reaches the provider.

With an endpoint named `my-llm` and the base URL `https://llm.example.com/openai`:

```text
https://proxy.tawaguard.com/<token>/my-llm/v1/chat/completions?api-version=2025-01-01
  goes to
https://llm.example.com/openai/v1/chat/completions?api-version=2025-01-01
```

The proxy forwards your own key header untouched. Send the key in the header
your provider expects.

<Tabs groupId="client" items="[&#x22;OpenAI SDK (Python)&#x22;, &#x22;OpenAI SDK (TypeScript)&#x22;, &#x22;curl&#x22;]">
  <Tab value="OpenAI SDK (Python)">
    For an endpoint that reads the key from `Authorization`, the SDK's `api_key`
    does the job.

    ```python
    import os

    from openai import OpenAI

    client = OpenAI(
        base_url=f"https://proxy.tawaguard.com/{os.environ['TAWA_PROXY_TOKEN']}/my-llm/v1",
        api_key=os.environ["MY_LLM_API_KEY"],
    )

    reply = client.chat.completions.create(
        model="<your model>",
        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}/my-llm/v1`,
      apiKey: process.env.MY_LLM_API_KEY,
    });

    const reply = await client.chat.completions.create({
      model: "<your model>",
      messages: [{ role: "user", content: "Hello" }],
    });
    console.log(reply.choices[0].message.content);
    ```
  </Tab>

  <Tab value="curl">
    An endpoint that reads the key from another header, such as `api-key` on an
    Azure OpenAI deployment, gets that header exactly as you send it.

    ```bash
    curl "https://proxy.tawaguard.com/$TAWA_PROXY_TOKEN/azure-eu/v1/chat/completions?api-version=2025-01-01" \
      -H "api-key: $AZURE_OPENAI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"model": "<your deployment>", "messages": [{"role": "user", "content": "Hello"}]}'
    ```
  </Tab>
</Tabs>

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

* The base URL must use HTTPS and a public address. An address in a private, loopback, link-local or similar range is rejected when you save, and again on every request.
* If the name resolves to a private address when a request arrives, the proxy returns `502` with `tawa_upstream_blocked` and sends nothing. If it cannot be resolved, the response is `502` with `tawa_upstream_unreachable`.
* Redirects from your endpoint are not followed.
* One entry serves only the paths of its format. An OpenAI-format endpoint serves `/chat/completions` and `/responses`. An Anthropic-format endpoint serves `/messages`.
* Your key passes through to your endpoint. Tawa Guard does not store it.
* The proxy does not change the model or deployment name in your request.

See [Error codes](/docs/proxy/reference/error-codes) and [Routing rules](/docs/proxy/reference/routing-rules).
