Use this file to discover all available pages before exploring further.
This guide covers cloud browsers powered by Kernel — cloud Chromium instances your code controls via CDP or the Kernel SDK. For local browser automation using a virtual desktop, see Computer use.
Cloud browsers run on Kernel’s managed infrastructure, not inside your sandbox. This gives you sub-second browser startup, persistent sessions you can pause and resume across hours or days, and reusable browser state. Your agent connects to them over the network via CDP, BiDi, or their CUA API.Kernel handles CAPTCHA solving, residential proxies, authentication, and observability out of the box.
Deploy a web app inside an E2B sandbox, get a public URL, then use a Kernel cloud browser to screenshot every route.
1
Create the sandbox and start your app
import { Sandbox } from 'e2b'// A minimal FastAPI app with three routes to screenshotconst FASTAPI_APP = `from fastapi import FastAPIfrom fastapi.responses import HTMLResponseapp = FastAPI()@app.get("/")def home(): return HTMLResponse("<h1>Home</h1><p>Welcome to the app.</p>")@app.get("/about")def about(): return HTMLResponse("<h1>About</h1><p>About this app.</p>")@app.get("/dashboard")def dashboard(): return HTMLResponse("<h1>Dashboard</h1><p>Your dashboard.</p>")`const sandbox = await Sandbox.create('kernel-browser', { envs: { KERNEL_API_KEY: process.env.KERNEL_API_KEY! }, timeoutMs: 300_000,})await sandbox.files.write('/home/user/app.py', FASTAPI_APP)await sandbox.commands.run( 'pip install fastapi uvicorn', { timeoutMs: 60_000 },)await sandbox.commands.run( 'uvicorn app:app --host 0.0.0.0 --port 8000', { background: true, cwd: '/home/user' },)
2
Screenshot each route with Kernel
E2B exposes any sandbox port as a public HTTPS endpoint. Write a browsing script into the sandbox that creates a Kernel browser and screenshots each route.
Use Browser Use to let an LLM autonomously browse a website and extract data. The agent sees the page via screenshots and decides what to click, type, and navigate.This requires an additional LLM API key:
The agent script runs inside the sandbox. Browser Use and its dependencies come pre-installed in the kernel-browser template. The script creates a Kernel browser, connects Browser Use, and completes the task autonomously.
const AGENT_SCRIPT = `import asynciofrom kernel import Kernelfrom browser_use import Agent, Browser, ChatAnthropicasync def main(): kernel = Kernel() kb = kernel.browsers.create() browser = Browser(cdp_url=kb.cdp_ws_url) agent = Agent( task="Go to https://news.ycombinator.com, find the top 5 stories, and return their titles and point counts as JSON", llm=ChatAnthropic(model="claude-sonnet-4"), browser=browser, ) result = await agent.run() print(result)asyncio.run(main())`await sandbox.files.write('/home/user/agent_task.py', AGENT_SCRIPT)const result = await sandbox.commands.run( 'python3 /home/user/agent_task.py', { timeoutMs: 180_000 },)console.log(result.stdout)await sandbox.kill()
Full example:
import { Sandbox } from 'e2b'// 1. Create the sandbox with API keysconst sandbox = await Sandbox.create('kernel-browser', { envs: { KERNEL_API_KEY: process.env.KERNEL_API_KEY!, ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY!, }, timeoutMs: 300_000,})// 2. Write and run the Browser Use agentconst AGENT_SCRIPT = `import asynciofrom kernel import Kernelfrom browser_use import Agent, Browser, ChatAnthropicasync def main(): kernel = Kernel() kb = kernel.browsers.create() browser = Browser(cdp_url=kb.cdp_ws_url) agent = Agent( task="Go to https://news.ycombinator.com, find the top 5 stories, and return their titles and point counts as JSON", llm=ChatAnthropic(model="claude-sonnet-4"), browser=browser, ) result = await agent.run() print(result)asyncio.run(main())`await sandbox.files.write('/home/user/agent_task.py', AGENT_SCRIPT)const result = await sandbox.commands.run( 'python3 /home/user/agent_task.py', { timeoutMs: 180_000 },)console.log(result.stdout)await sandbox.kill()
Kernel provides a live view URL for every browser session — you can watch the browser in real time or embed it in your app. This is useful for debugging, demos, or letting users see what the agent is doing.
import { Sandbox } from 'e2b'const sandbox = await Sandbox.create('kernel-browser', { envs: { KERNEL_API_KEY: process.env.KERNEL_API_KEY! }, timeoutMs: 300_000,})const LIVE_VIEW_SCRIPT = `from kernel import Kernelkernel = Kernel()browser = kernel.browsers.create()# Print the live view URL — accessible from any browserprint(browser.browser_live_view_url)`await sandbox.files.write('/home/user/live_view.py', LIVE_VIEW_SCRIPT)const result = await sandbox.commands.run( 'python3 /home/user/live_view.py', { timeoutMs: 30_000 },)const liveViewUrl = result.stdout.trim()console.log('Watch the browser:', liveViewUrl)// Embed in your app as an iframe// <iframe src={liveViewUrl}></iframe>// Read-only mode (no mouse/keyboard interaction)// liveViewUrl + '?readOnly=true'
The live view URL stays active until the browser is deleted or times out. For more details, see the Kernel live view documentation.