> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/vercel-labs/agent-browser/llms.txt
> Use this file to discover all available pages before exploring further.

# Kernel

> Cloud browser infrastructure with stealth mode and persistent profiles

[Kernel](https://www.kernel.sh) provides cloud browser infrastructure for AI agents with features like stealth mode and persistent profiles.

## When to Use Kernel

* Bot detection avoidance (stealth mode)
* Persistent login sessions across runs
* Cloud deployment without local browser
* Fingerprint resistance
* Enterprise-grade browser infrastructure

## Prerequisites

* Kernel account ([sign up](https://www.kernel.sh))
* API key from [Kernel Dashboard](https://dashboard.onkernel.com)

## Setup

<Steps>
  <Step title="Get your API key">
    1. Visit the [Kernel Dashboard](https://dashboard.onkernel.com)
    2. Navigate to API settings
    3. Create and copy your API key
  </Step>

  <Step title="Set environment variable">
    ```bash theme={null}
    export KERNEL_API_KEY="your-api-key"
    ```
  </Step>
</Steps>

## Usage

### Via CLI Flag

Use the `-p kernel` flag:

```bash theme={null}
agent-browser -p kernel open https://example.com
agent-browser -p kernel snapshot -i
agent-browser -p kernel click @e1
```

### Via Environment Variable

Set the provider globally:

```bash theme={null}
export AGENT_BROWSER_PROVIDER=kernel
export KERNEL_API_KEY="your-api-key"

# Now all commands use Kernel automatically
agent-browser open https://example.com
agent-browser snapshot -i
agent-browser click @e1
```

## Configuration

### Environment Variables

<table>
  <thead>
    <tr>
      <th>Variable</th>
      <th>Description</th>
      <th>Default</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>AGENT\_BROWSER\_PROVIDER</code></td>
      <td>Set to <code>kernel</code></td>
      <td>-</td>
    </tr>

    <tr>
      <td><code>KERNEL\_API\_KEY</code></td>
      <td>Your Kernel API key</td>
      <td>Required</td>
    </tr>

    <tr>
      <td><code>KERNEL\_HEADLESS</code></td>
      <td>Run browser in headless mode (<code>true</code>/<code>false</code>)</td>
      <td><code>false</code></td>
    </tr>

    <tr>
      <td><code>KERNEL\_STEALTH</code></td>
      <td>Enable stealth mode to avoid bot detection (<code>true</code>/<code>false</code>)</td>
      <td><code>true</code></td>
    </tr>

    <tr>
      <td><code>KERNEL\_TIMEOUT\_SECONDS</code></td>
      <td>Session timeout in seconds</td>
      <td><code>300</code></td>
    </tr>

    <tr>
      <td><code>KERNEL\_PROFILE\_NAME</code></td>
      <td>Browser profile name for persistent cookies/logins</td>
      <td>None</td>
    </tr>
  </tbody>
</table>

### Stealth Mode

Stealth mode (enabled by default) helps avoid bot detection:

```bash theme={null}
# Stealth enabled (default)
export KERNEL_STEALTH=true
agent-browser -p kernel open https://example.com

# Disable stealth if not needed
export KERNEL_STEALTH=false
agent-browser -p kernel open https://example.com
```

### Persistent Profiles

Use profiles to persist cookies, logins, and session data across browser restarts:

```bash theme={null}
export KERNEL_PROFILE_NAME="myapp-session"

# First run - login and session is saved
agent-browser -p kernel open https://app.example.com/login
agent-browser -p kernel snapshot -i
agent-browser -p kernel fill @e1 "user@example.com"
agent-browser -p kernel fill @e2 "password"
agent-browser -p kernel click @e3
agent-browser -p kernel close  # Profile saved automatically

# Second run - reuses saved session
agent-browser -p kernel open https://app.example.com/dashboard
# Already logged in!
```

<Note>
  When `KERNEL_PROFILE_NAME` is set, the profile is created if it doesn't exist. Cookies, logins, and session data are automatically saved when the browser session ends.
</Note>

## Features

All standard agent-browser commands work with Kernel:

* **Navigation**: Full page navigation support
* **Snapshots**: Accessibility tree with refs
* **Interactions**: Click, fill, type, press, hover
* **Screenshots**: Standard and annotated screenshots
* **State Management**: Cookies, localStorage, sessionStorage
* **Network Control**: Route, intercept, mock responses

## Example: Persistent Login Session

```bash theme={null}
#!/bin/bash
# login-once.sh - Login is saved to profile

export AGENT_BROWSER_PROVIDER=kernel
export KERNEL_API_KEY="your-api-key"
export KERNEL_PROFILE_NAME="github-session"
export KERNEL_STEALTH=true

# Login once
agent-browser open https://github.com/login
agent-browser snapshot -i
agent-browser fill @e1 "username"
agent-browser fill @e2 "password"
agent-browser click @e3
agent-browser wait --url "**/github.com"
agent-browser close

echo "Session saved to profile: github-session"
```

```bash theme={null}
#!/bin/bash
# reuse-session.sh - Reuses saved login

export AGENT_BROWSER_PROVIDER=kernel
export KERNEL_API_KEY="your-api-key"
export KERNEL_PROFILE_NAME="github-session"

# Already logged in from previous session
agent-browser open https://github.com/settings
agent-browser snapshot -i
```

## Example: Stealth Scraping

```bash theme={null}
# Avoid bot detection with stealth mode
export AGENT_BROWSER_PROVIDER=kernel
export KERNEL_API_KEY="your-api-key"
export KERNEL_STEALTH=true

agent-browser open https://protected-site.com
agent-browser wait --load networkidle
agent-browser snapshot -i --json > data.json
agent-browser close
```

## Example: CI/CD with Persistent Auth

```yaml theme={null}
# .github/workflows/deploy.yml
name: Deploy Dashboard

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Install agent-browser
        run: npm install -g agent-browser
      
      - name: Deploy via admin panel
        env:
          AGENT_BROWSER_PROVIDER: kernel
          KERNEL_API_KEY: ${{ secrets.KERNEL_API_KEY }}
          KERNEL_PROFILE_NAME: admin-session
          KERNEL_STEALTH: true
        run: |
          # Profile persists between CI runs
          agent-browser open https://admin.example.com/deploy
          agent-browser snapshot -i
          agent-browser click @e5  # Click deploy button
          agent-browser wait --text "Deployment successful"
          agent-browser screenshot deploy-success.png
```

## Profile Management

Profiles are managed server-side by Kernel:

* **Auto-creation**: Profiles are created automatically on first use
* **Persistence**: Session data persists across browser restarts
* **Isolation**: Each profile name is isolated from others
* **Cleanup**: Profiles expire based on your Kernel plan settings

## Pricing

Check current pricing and plans at [kernel.sh/pricing](https://www.kernel.sh/pricing).

<Tip>
  Use `KERNEL_PROFILE_NAME` to maintain authenticated sessions across deployments, CI/CD runs, or scheduled tasks without re-logging in every time.
</Tip>
