> ## Documentation Index
> Fetch the complete documentation index at: https://self-hosted-docs.relai.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Choosing an LLM provider

> OpenAI is the default, but the backend also supports Azure OpenAI, AWS Bedrock, direct Anthropic/Claude, Vertex AI, Microsoft Foundry, and local OSS models.

By default, the backend uses OpenAI (`OPENAI_API_KEY` in `.env`). If you'd
rather use a different provider — your own Azure OpenAI deployment, AWS
Bedrock, Anthropic directly, or something else — it's configurable.

<Info>
  You don't have to redeploy to switch providers. This is also configurable
  live from Django Admin (**Agent Studio → Coding agent runtime configs**),
  which takes precedence over `.env` once you enable a config there. Use
  `.env` for the version you want to ship with by default, and Django Admin
  if you want to change it afterward without restarting containers.
</Info>

## Two tracks

`RELAI_AGENT_PROVIDER` picks which track you're on:

* **`codex`** (the default) — an OpenAI-compatible track. Works with OpenAI,
  Azure OpenAI, AWS Bedrock, or any OpenAI-compatible gateway.
* **`claude`** — an Anthropic-compatible track. Works with direct Anthropic,
  or Claude on AWS Bedrock, Google Vertex AI, AWS Marketplace, or Microsoft
  Foundry.

Within whichever track you pick, `RELAI_AGENT_MODEL_PROVIDER` selects the
concrete backend. The sections below cover each one.

<Tabs sync={false}>
  <Tab title="OpenAI (default)">
    Nothing extra to configure beyond what's already in
    [Configuration](/configuration):

    ```sh theme={"system"}
    OPENAI_API_KEY="sk-..."
    ```
  </Tab>

  <Tab title="Azure OpenAI">
    ```sh theme={"system"}
    RELAI_AGENT_PROVIDER="codex"
    RELAI_AGENT_MODEL_PROVIDER="azure"
    RELAI_AGENT_MODEL="<your-azure-deployment-name>"
    RELAI_AGENT_BASE_URL="https://<your-resource>.openai.azure.com"
    RELAI_AGENT_API_KEY_ENV="AZURE_OPENAI_API_KEY"
    RELAI_AGENT_QUERY_PARAMS={"api-version": "<azure-api-version>"}
    AZURE_OPENAI_API_KEY="..."
    ```

    `RELAI_AGENT_MODEL_PROVIDER` doesn't have to be literally `azure` — any
    custom value works, it's just a label. What matters is `RELAI_AGENT_BASE_URL`
    pointing at your deployment endpoint and the API version going through
    `RELAI_AGENT_QUERY_PARAMS`.
  </Tab>

  <Tab title="AWS Bedrock">
    Native Codex on Bedrock:

    ```sh theme={"system"}
    RELAI_AGENT_PROVIDER="codex"
    RELAI_AGENT_MODEL_PROVIDER="amazon-bedrock"
    RELAI_AGENT_MODEL="openai.gpt-5.4"
    RELAI_AGENT_AWS_REGION="<your-aws-region>"
    ```

    Leave `RELAI_AGENT_API_KEY_ENV` unset. For SDK-based auth, use an AWS
    profile or the default AWS credential chain; for Bedrock API-key auth,
    set `AWS_BEARER_TOKEN_BEDROCK` in the container environment instead.

    For an AWS-hosted OpenAI-compatible gateway instead of native Bedrock:

    ```sh theme={"system"}
    RELAI_AGENT_PROVIDER="codex"
    RELAI_AGENT_MODEL_PROVIDER="aws"
    RELAI_AGENT_BASE_URL="https://<your-gateway-endpoint>"
    RELAI_AGENT_API_KEY_ENV="<YOUR_GATEWAY_KEY_ENV>"
    ```
  </Tab>

  <Tab title="Direct Anthropic">
    ```sh theme={"system"}
    RELAI_AGENT_PROVIDER="claude"
    RELAI_AGENT_MODEL="claude-sonnet-4-6"
    RELAI_CLAUDE_API_KEY_ENV="ANTHROPIC_API_KEY"
    ANTHROPIC_API_KEY="sk-ant-..."
    ```
  </Tab>

  <Tab title="Claude on Bedrock / Vertex / Foundry">
    Claude on AWS Bedrock:

    ```sh theme={"system"}
    RELAI_AGENT_PROVIDER="claude"
    RELAI_AGENT_MODEL_PROVIDER="bedrock"
    RELAI_AGENT_MODEL="<bedrock-model-id>"
    RELAI_AGENT_AWS_REGION="<your-aws-region>"
    ```

    Claude on Google Vertex AI:

    ```sh theme={"system"}
    RELAI_AGENT_PROVIDER="claude"
    RELAI_AGENT_MODEL_PROVIDER="vertex"
    RELAI_AGENT_VERTEX_PROJECT_ID="<your-gcp-project>"
    RELAI_AGENT_VERTEX_REGION="<your-gcp-region>"
    ```

    Claude on Microsoft Foundry:

    ```sh theme={"system"}
    RELAI_AGENT_PROVIDER="claude"
    RELAI_AGENT_MODEL_PROVIDER="foundry"
    RELAI_AGENT_FOUNDRY_RESOURCE="<your-foundry-resource>"
    # Leave RELAI_CLAUDE_API_KEY_ENV unset to use Entra ID/gateway auth,
    # or set it to an env var containing your Foundry API key.
    ```
  </Tab>

  <Tab title="Local OSS models">
    Codex-only, via a local model runner:

    ```sh theme={"system"}
    RELAI_AGENT_PROVIDER="codex"
    RELAI_AGENT_OSS="true"
    RELAI_AGENT_LOCAL_PROVIDER="ollama"  # or "lmstudio"
    ```
  </Tab>
</Tabs>

<Warning>
  Not every combination is valid — for example, the `claude` track only
  accepts `anthropic`, `bedrock`, `vertex`, `anthropic-aws`, or `foundry` as
  a model provider, and the `codex` track rejects those same values. If a
  config is invalid, the backend will tell you exactly what's wrong when it
  starts up or when you try to enable it in Django Admin.
</Warning>
