---
title: "Kernel integration"
description: "Pair an E2B sandbox with a Kernel cloud browser over CDP. Run your app or agent in the sandbox and drive Chromium on Kernel with Playwright."
url: "https://e2b.dev/integrations/kernel"
---

# Kernel

> Give the code in your sandbox a cloud browser. Your script runs in E2B and drives Chromium on Kernel over CDP with Playwright.

Browser & computer use · [All integrations](https://e2b.dev/integrations.md)

## About this integration

- **Maintained by:** E2B
- **How it works:** kernel-browser template, CDP
- **Package:** kernel, @onkernel/sdk
- **Language:** Python, TypeScript
- **Upstream:** [kernel/kernel-images · ★ 1.1k](https://github.com/kernel/kernel-images)
- **Docs:** [Cloud browser guide](https://docs.e2b.dev/use-cases/remote-browser)

## Get started

Paste the prompt into your coding agent, or follow the steps yourself.

### Paste this into your coding agent

```text
Add E2B sandboxes and Kernel browsers to this project.

1. Install e2b, the Kernel SDK and Playwright (e2b kernel playwright for Python, e2b @onkernel/sdk playwright-core for TypeScript) using the project's package manager.
2. The code needs the E2B_API_KEY environment variable. If it isn't set, ask me for my API key from https://console.e2b.dev/?tab=keys. Never hardcode it. Ask me for KERNEL_API_KEY the same way.
3. Follow the cloud browser guide at https://docs.e2b.dev/use-cases/remote-browser: create a sandbox from the kernel-browser template with KERNEL_API_KEY in its envs, and run a script there that opens a Kernel browser and connects Playwright over CDP.
4. Run it once and show me the output that came from the sandbox, then kill the sandbox.
```

## Or set it up yourself

### 1. Install the SDKs

```bash
pip install e2b kernel playwright
```

### 2. Set your API keys

```bash
E2B_API_KEY=e2b_***
KERNEL_API_KEY=kernel_***
```

### 3. Start a sandbox and your app

```python
import os
from e2b import Sandbox

FASTAPI_APP = """
from fastapi import FastAPI
from fastapi.responses import HTMLResponse

app = FastAPI()

@app.get("/")
def home():
    return HTMLResponse("<h1>Home</h1><p>Welcome to the app.</p>")
"""

sandbox = Sandbox.create(
    "kernel-browser",
    envs={"KERNEL_API_KEY": os.environ["KERNEL_API_KEY"]},
    timeout=300,
)

sandbox.files.write("/home/user/app.py", FASTAPI_APP)
sandbox.commands.run("pip install fastapi uvicorn", timeout=60)
sandbox.commands.run(
    "uvicorn app:app --host 0.0.0.0 --port 8000",
    background=True,
    cwd="/home/user",
)
```

### 4. Screenshot it with a Kernel browser

```python
app_url = f"https://{sandbox.get_host(8000)}"

BROWSE_SCRIPT = f'''
from kernel import Kernel
from playwright.sync_api import sync_playwright

kernel = Kernel()
kb = kernel.browsers.create()

with sync_playwright() as pw:
    browser = pw.chromium.connect_over_cdp(kb.cdp_ws_url)
    page = browser.new_page()
    page.goto("{app_url}/", wait_until="networkidle")
    page.screenshot(path="/home/user/home.png")
    print("Captured /")
    browser.close()
'''

sandbox.files.write("/home/user/browse.py", BROWSE_SCRIPT)
result = sandbox.commands.run("python3 /home/user/browse.py", timeout=60)
print(result.stdout)
sandbox.kill()
```

## What runs in the sandbox

Your app and browsing scripts run in E2B. The browser itself runs on Kernel's infrastructure.

- **Code:** Your app and scripts, in a sandbox from the kernel-browser template with the Kernel SDK, Playwright and Browser Use installed.
- **Browser:** Chromium runs on Kernel, not in the sandbox. Scripts connect to it over CDP.
- **Network:** Any sandbox port gets a public HTTPS URL from get_host, so the Kernel browser can load the app you started.
- **Secrets:** KERNEL_API_KEY goes into the sandbox through envs. Your E2B key stays on your machine.

## More browser & computer use

Other ways to give agents a browser or a desktop on E2B.

- [Playwright](https://docs.e2b.dev/use-cases/remote-browser): Run Playwright inside a sandbox, or connect it to a remote browser from one.
- [OpenAI computer use](https://docs.e2b.dev/agents/openai-computer-use): Give OpenAI's computer-use model an E2B Desktop to see and control.
- [Claude browser and computer-use toolsets](https://docs.e2b.dev/agents/claude-toolsets): Back Claude's browser and computer-use toolsets with E2B drivers in Python or TypeScript.

## Links

- [Get API key](https://console.e2b.dev/?tab=keys)
- [Read the docs](https://docs.e2b.dev/use-cases/remote-browser)
- [E2B documentation](https://docs.e2b.dev)
