> ## Documentation Index
> Fetch the complete documentation index at: https://bifrost-dev.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Passthrough

> Forward provider-native requests through Bifrost with full core pipeline processing, including logs and observability.

## Overview

Passthrough integrations let you call provider-native API paths and payloads through Bifrost without route-level request/response conversion.

When you use passthrough endpoints, the request still flows through Bifrost core logic. You keep Bifrost features such as logging and observability while sending provider-native paths and bodies.

***

## Endpoints

* `/openai_passthrough`
  Default provider: `openai`
* `/anthropic_passthrough`
  Default provider: `anthropic`
* `/azure_passthrough`
  Default provider: `azure`
* `/genai_passthrough`
  Default provider: `gemini` (with automatic Vertex detection for clients configured to use Vertex)

***

## How It Works

1. Send your request to a passthrough endpoint (OpenAI, Anthropic, Azure, or GenAI passthrough).
2. The integration strips the passthrough prefix and forwards the remaining provider-native path/body.
3. **Bifrost picks the provider key.** Client-supplied provider credentials (`authorization`, `api-key`, `x-api-key`, `x-goog-api-key`) are stripped from the request, and Bifrost selects a key from its own key config for the resolved provider and model.
4. Bifrost handles provider execution through core inference and plugin pipelines.
5. Response status, headers, and body are returned as passthrough output (for both stream and non-stream requests).

<Warning>
  **Authenticate to Bifrost with your Bifrost virtual key, not your provider API key.** Passthrough is not a credential proxy — provider keys in the incoming request are never forwarded upstream. Bifrost always injects the key it selects from its configured keys.
</Warning>

<Note>
  Claude Code OAuth sign-in (`Authorization: Bearer sk-ant-oat…`) is handled separately on the regular `/anthropic` route, where Bifrost forwards the caller's token instead of selecting a key. Point Claude Code there — no passthrough endpoint needed. See [Claude Code authentication](../cli-agents/claude-code#anthropic_custom_headers-alternative).
</Note>

***

## Provider Selection Rules

### OpenAI Passthrough

* Uses `openai` as the default provider.

### Anthropic Passthrough

* Uses `anthropic` as the default provider.

### Azure Passthrough

* Uses `azure` as the default provider.
* Requires an Azure key with `endpoint` configured.
* **`api-version` handling varies by route:**
  * `/openai/deployments/` routes: if the caller omits `api-version`, Bifrost injects a default (`2025-04-01-preview`). Pass your own `api-version` to override — for example, to pin to a GA version or use a specific preview version.

### GenAI Passthrough

* Uses `gemini` by default.
* Automatically switches to `vertex` when Vertex patterns are detected, such as:
  * URL path containing `/projects/{PROJECT_ID}/locations/{LOCATION}/`
  * Request body `model` containing a Vertex resource path
  * OAuth token pattern typically used for Vertex (`Bearer ya29...`)

***

## Usage Examples

### OpenAI Passthrough

<Tabs group="openai-passthrough">
  <Tab title="Python SDK">
    ```python theme={null}
    import openai

    client = openai.OpenAI(
        base_url="http://localhost:8080/openai_passthrough/v1",
        api_key="<YOUR-BIFROST-VIRTUAL-KEY>"  # Replace with your actual Bifrost virtual key.
    )

    response = client.chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": "hello from passthrough"}]
    )

    print(response.choices[0].message.content)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "http://localhost:8080/openai_passthrough/v1/chat/completions" \
      -H "content-type: application/json" \
      -H "authorization: Bearer <YOUR-BIFROST-VIRTUAL-KEY>" \
      -d '{
        "model": "gpt-4o-mini",
        "messages": [{"role":"user","content":"hello from passthrough"}]
      }'
    ```
  </Tab>
</Tabs>

### Anthropic Passthrough

<Tabs group="anthropic-passthrough">
  <Tab title="Python SDK">
    ```python theme={null}
    import anthropic

    client = anthropic.Anthropic(
        base_url="http://localhost:8080/anthropic_passthrough",
        api_key="<YOUR-BIFROST-VIRTUAL-KEY>"  # Replace with your actual Bifrost virtual key.
    )

    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=1024,
        messages=[{"role": "user", "content": "hello from passthrough"}]
    )

    print(response.content[0].text)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "http://localhost:8080/anthropic_passthrough/v1/messages" \
      -H "content-type: application/json" \
      -H "x-api-key: <YOUR-BIFROST-VIRTUAL-KEY>" \
      -H "anthropic-version: 2023-06-01" \
      -d '{
        "model": "claude-sonnet-4-20250514",
        "max_tokens": 1024,
        "messages": [{"role":"user","content":"hello from passthrough"}]
      }'
    ```
  </Tab>
</Tabs>

### Azure Passthrough

<Tabs group="azure-passthrough">
  <Tab title="Azure OpenAI SDK">
    ```python theme={null}
    from openai import AzureOpenAI

    client = AzureOpenAI(
        azure_endpoint="http://localhost:8080/azure_passthrough",
        api_key="<YOUR-BIFROST-VIRTUAL-KEY>",  # Replace with your actual Bifrost virtual key.
        api_version="2024-10-21",  # passed through as-is in the query string
    )

    response = client.chat.completions.create(
        model="gpt-4o",  # your Azure deployment name
        messages=[{"role": "user", "content": "hello from azure passthrough"}]
    )

    print(response.choices[0].message.content)
    ```
  </Tab>

  <Tab title="OpenAI SDK">
    ```python theme={null}
    from openai import OpenAI

    client = OpenAI(
        base_url="http://localhost:8080/azure_passthrough/openai/v1/",
        api_key="<YOUR-BIFROST-VIRTUAL-KEY>",  # Replace with your actual Bifrost virtual key.
    )

    response = client.responses.create(
        model="gpt-4.1",  # your Azure deployment name
        input="hello from azure passthrough",
    )

    print(response.output_text)
    ```
  </Tab>

  <Tab title="Anthropic SDK (Anthropic on Azure)">
    ```python theme={null}
    import anthropic

    client = anthropic.Anthropic(
        base_url="http://localhost:8080/azure_passthrough",
        api_key="<YOUR-BIFROST-VIRTUAL-KEY>",  # Replace with your actual Bifrost virtual key.
    )

    response = client.messages.create(
        model="claude-sonnet-4-20250514",
        max_tokens=1024,
        messages=[{"role": "user", "content": "hello from azure passthrough"}]
    )

    print(response.content[0].text)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "http://localhost:8080/azure_passthrough/openai/deployments/gpt-4o/chat/completions?api-version=2025-04-01-preview" \
      -H "content-type: application/json" \
      -H "api-key: <YOUR-BIFROST-VIRTUAL-KEY>" \
      -d '{
        "messages": [{"role": "user", "content": "hello from azure passthrough"}]
      }'
    ```
  </Tab>
</Tabs>

### GenAI Passthrough (Gemini)

<Tabs group="genai-passthrough">
  <Tab title="Python SDK">
    ```python theme={null}
    from google import genai
    from google.genai.types import HttpOptions

    client = genai.Client(
        api_key="<YOUR-BIFROST-VIRTUAL-KEY>",  # Replace with your actual Bifrost virtual key.
        http_options=HttpOptions(base_url="http://localhost:8080/genai_passthrough")
    )

    response = client.models.generate_content(
        model="gemini-2.5-flash",
        contents="hello from passthrough"
    )

    print(response.text)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "http://localhost:8080/genai_passthrough/v1beta/models/gemini-2.5-flash:generateContent" \
      -H "content-type: application/json" \
      -H "x-goog-api-key: <YOUR-BIFROST-VIRTUAL-KEY>" \
      -d '{
        "contents":[{"parts":[{"text":"hello from passthrough"}]}]
      }'
    ```
  </Tab>
</Tabs>

### GenAI Passthrough (Vertex-style request)

<Tabs group="vertex-passthrough">
  <Tab title="Python SDK">
    ```python theme={null}
    from google import genai
    from google.genai.types import HttpOptions

    client = genai.Client(
        vertexai=True,
        api_key="<YOUR-BIFROST-VIRTUAL-KEY>",  # Replace with your actual Bifrost virtual key.
        http_options=HttpOptions(base_url="http://localhost:8080/genai_passthrough")
    )

    response = client.models.generate_content(
        model="gemini-2.5-flash",
        contents="hello from vertex passthrough"
    )

    print(response.text)
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "http://localhost:8080/genai_passthrough/v1/projects/my-project/locations/us-central1/publishers/google/models/gemini-2.5-flash:generateContent" \
      -H "content-type: application/json" \
      -H "authorization: Bearer <YOUR-BIFROST-VIRTUAL-KEY>" \
      -d '{
        "contents":[{"parts":[{"text":"hello from vertex passthrough"}]}]
      }'
    ```
  </Tab>
</Tabs>

***

## Notes

* Use passthrough when you need a provider endpoint that is not directly supported by Bifrost integration routes yet.
* **Provider key selection is done by Bifrost, not by the caller.** On every passthrough endpoint, the client's `authorization`, `api-key`, `x-api-key`, and `x-goog-api-key` headers are dropped before the request leaves Bifrost, and the upstream auth header (including Azure's `api-key` / OAuth token) is set from the Bifrost key config.
* The only exception is [direct API keys](../providers/request-options#direct-api-key), which need both the server-side `allow_direct_keys` setting and a per-request `x-bf-direct-key: true` header. Without both, a raw provider key in the request is ignored.
* For Azure `/openai/deployments/` routes, Bifrost injects `api-version=2025-04-01-preview` when the caller does not supply one. Supply your own `api-version` query parameter to use a different version (e.g. `2024-10-21` for the latest GA, or a newer preview).
