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

# Model Gateway

> Access top LLM providers through your Browserbase API key — one key, one bill, no provider accounts needed.

Model Gateway lets you use [Stagehand](https://docs.stagehand.dev/) without wiring up model providers yourself. Instead of managing separate API keys for OpenAI, Anthropic, and Google, just use your Browserbase API key and pick a model. Browserbase routes the request to the upstream provider for you.

## Setup

When you provide only a Browserbase API key (without a provider-specific key), Stagehand automatically routes model requests through Model Gateway. No additional configuration needed.

```typescript theme={null}
import { Stagehand } from "@browserbasehq/stagehand";

const stagehand = new Stagehand({
  env: "BROWSERBASE",
  apiKey: process.env.BROWSERBASE_API_KEY,
  model: "openai/gpt-5",
});

await stagehand.init();
```

Compare this to the traditional setup, where you manage both a Browserbase key and a separate provider key:

```typescript theme={null}
// without Model Gateway — you manage two sets of credentials
const stagehand = new Stagehand({
  env: "BROWSERBASE",
  apiKey: process.env.BROWSERBASE_API_KEY,
  model: {
    modelName: "openai/gpt-5",
    apiKey: process.env.OPENAI_API_KEY,
  },
});
```

<Note>
  Model Gateway requires Browserbase-hosted browsers. It does not work with `env: "LOCAL"`.
</Note>

## Switching models

With Model Gateway, switching between providers is a config change — no new accounts, API keys, or code rewiring required:

<Tabs>
  <Tab title="OpenAI">
    ```typescript theme={null}
    const stagehand = new Stagehand({
      env: "BROWSERBASE",
      apiKey: process.env.BROWSERBASE_API_KEY,
      model: "openai/gpt-5",
    });
    ```
  </Tab>

  <Tab title="Anthropic">
    ```typescript theme={null}
    const stagehand = new Stagehand({
      env: "BROWSERBASE",
      apiKey: process.env.BROWSERBASE_API_KEY,
      model: "anthropic/claude-sonnet-4-6",
    });
    ```
  </Tab>

  <Tab title="Google">
    ```typescript theme={null}
    const stagehand = new Stagehand({
      env: "BROWSERBASE",
      apiKey: process.env.BROWSERBASE_API_KEY,
      model: "google/gemini-2.5-flash",
    });
    ```
  </Tab>
</Tabs>

## Key benefits

* **One key, one bill** — LLM inference, browser infrastructure, and caching all run through your Browserbase API key. No separate provider accounts to manage.
* **Market-price tokens** — Tokens are billed at the same price as going direct to the provider. No markup.
* **Built-in reliability** — Retries, backoff, and rate limit handling are managed for you.
* **No tier-gating** — Access new models immediately without hitting provider spend thresholds. No need to "earn" access to the latest releases.
* **Action caching** — Model Gateway works with Stagehand's managed action caching, so repeated steps are reused instead of re-run, reducing cost and latency across sessions.

## Supported providers

| Provider  | Example Model                 |
| --------- | ----------------------------- |
| OpenAI    | `openai/gpt-5`                |
| Anthropic | `anthropic/claude-sonnet-4-6` |
| Google    | `google/gemini-2.5-flash`     |

<Tip>
  Need a provider that isn't listed? [Reach out](https://www.browserbase.com/contact) — Browserbase is happy to work with teams on additional model support.
</Tip>

## Pricing

Model Gateway tokens are billed at market price — the same rate you'd pay going direct to the provider. There is no additional markup. Usage appears on your existing Browserbase bill alongside browser time, proxy bandwidth, and other platform usage.

See [Plans](/account/billing/plans) for details on included allocations and overages.

## Next steps

<CardGroup cols={2}>
  <Card title="Stagehand" icon="wand-magic-sparkles" iconType="sharp-solid" href="https://docs.stagehand.dev/">
    The AI SDK for browser agents. Natural language selectors, self-healing actions, and built-in caching.
  </Card>

  <Card title="Functions" icon="function" iconType="sharp-solid" href="/platform/runtime/overview">
    Deploy your Stagehand agents as serverless functions on Browserbase infrastructure.
  </Card>
</CardGroup>
