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

# LLM Providers

> Configure OpenAI, Anthropic, Google Gemini as your LLM provider

HyperAgent supports multiple LLM providers with native SDK integration. All models from each provider are supported—use whichever fits your needs.

## Supported Providers

| Provider      | Models                                                               | Environment Variable |
| ------------- | -------------------------------------------------------------------- | -------------------- |
| OpenAI        | [All models](https://platform.openai.com/docs/models)                | `OPENAI_API_KEY`     |
| Anthropic     | [All models](https://docs.anthropic.com/en/docs/about-claude/models) | `ANTHROPIC_API_KEY`  |
| Google Gemini | [All models](https://ai.google.dev/gemini-api/docs/models/gemini)    | `GEMINI_API_KEY`     |

## Configuration

### OpenAI

```typescript theme={null}
import { HyperAgent } from "@hyperbrowser/agent";

const agent = new HyperAgent({
  llm: {
    provider: "openai",
    model: "gpt-5.1",
  },
});
```

### Anthropic

```typescript theme={null}
const agent = new HyperAgent({
  llm: {
    provider: "anthropic",
    model: "claude-sonnet-4-5",
  },
});
```

### Google Gemini

```typescript theme={null}
const agent = new HyperAgent({
  llm: {
    provider: "gemini",
    model: "gemini-3-pro-preview",
  },
});
```

## Environment Setup

Create a `.env` file in your project root:

```bash theme={null}
# Add the API key for your chosen provider
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GEMINI_API_KEY=...
```

Load it in your code:

```typescript theme={null}
import { config } from "dotenv";
config();

const agent = new HyperAgent({
  llm: {
    provider: "openai",
    model: "gpt-5.1",
  },
});
```

## Switching Providers

Create agents with different providers for different tasks:

```typescript theme={null}
// Use Claude for complex reasoning
const complexAgent = new HyperAgent({
  llm: { provider: "anthropic", model: "claude-sonnet-4-5" },
});

// Use a smaller model for simple tasks
const simpleAgent = new HyperAgent({
  llm: { provider: "openai", model: "gpt-5-mini" },
});
```

## Cost Optimization

Token costs vary by provider and model. To reduce costs:

1. Use `page.perform()` instead of `page.ai()` when possible (single LLM call vs. multiple)
2. Use [Action Caching](/hyperagent/action-cache) to replay without LLM calls
3. Use smaller/cheaper models for simple tasks

## Next Steps

<CardGroup cols={2}>
  <Card title="Browser Providers" icon="browser" href="/hyperagent/browser-providers">
    Configure local vs cloud browsers
  </Card>

  <Card title="Action Caching" icon="database" href="/hyperagent/action-cache">
    Replay automations without LLM calls
  </Card>
</CardGroup>
