- Run the finished example: clone and run with two commands
- Research across multiple pages: reuse one Kernel session to scan multiple pages
- Computer use controls: screenshot, click, and type for vision-model agents
What you need
- A Runloop API key
- A Kernel API key
- Python 3.12+ and
pip, or Node.js 18+ andnpm
Environment variables
Instead of exporting
KERNEL_API_KEY, store it as a Runloop account secret and map it into the devbox at runtime. See Account Secrets.Run the finished example
Clone the repo, install dependencies, then create the blueprint and run the browser task.create-blueprint bakes the Kernel SDK into a reusable blueprint, and run creates a devbox from it, uploads the agent, and drives a Kernel browser. The rest of this guide walks through each of those pieces.
How the example is built
To build it yourself, install the Runloop SDK locally. The devbox installs the Kernel SDK itself (baked into the blueprint below), so nothing else is needed on your machine.Create a blueprint with the Kernel SDK
Bake the Kernel SDK into a blueprint once so every devbox starts ready, with no install step.Create a devbox and run a browser task
Create a devbox from the blueprint withKERNEL_API_KEY injected, then have it create a Kernel browser and run a Playwright snippet against it. The snippet is JavaScript; page, context, and browser are in scope, and its return value comes back as result.
Here the agent returns structured JSON (title, headings, and link count) rather than a single string, which is the first useful browser primitive. The TypeScript version below orchestrates Runloop from Node, but the in-devbox agent is still Python, so the blueprint only needs the Python Kernel SDK.
The Kernel SDK is the only dependency the devbox needs. There is no Chromium or Playwright install, because the browser runs on Kernel.
Research across multiple pages
To research several pages, reuse one Kernel session: it avoids a cold start per page and preserves cookies and history. Define a reusablescan function that navigates and returns clean JSON, then call it for each URL inside one try/finally. This code goes in the same in-devbox agent shown above.
finally so the session is deleted even if a navigation raises.
Computer use controls
Some agents reason over pixels rather than the DOM, such as Claude or OpenAI computer-use models. Kernel’s Computer Controls API exposes screenshot, click, type, and scroll against the managed browser. Because Computer Controls has no navigate action, load the page once with Playwright Execute, then switch to the pixel API. These calls go inside the same in-devbox agent shown above (Python by default; the TypeScript equivalent is shown for reference). Wrapping the work intry/finally deletes the Kernel session even if a call fails.
How the integration works internally
- A devbox boots from a blueprint with the Kernel SDK already installed.
KERNEL_API_KEYis injected into the devbox environment.- The agent calls
browsers.create()to get a Kernel cloud browser session. - It drives the browser with
browsers.playwright.execute(), which runs the Playwright code co-located with the browser on Kernel and returns structured data. No CDP connection, no local browser. - Results return to the devbox; the orchestrator reads them and shuts the devbox down.
Common issues
resource_size_requestrejected- The enum is upper-case (
SMALL,MEDIUM,LARGE, …). Lower-case values return a 400.
- The enum is upper-case (
- Kernel auth errors inside the devbox
- Confirm
KERNEL_API_KEYwas passed viaenvironment_variableswhen creating the devbox.
- Confirm
playwright.executecode fails to parse- The
codeis JavaScript, not Python.page,context, andbrowserare in scope.
- The
- No live view URL
browser_live_view_urlis null for headless browsers. Kernel browsers are headful by default.
Next Steps
- Full runnable source: the Kernel example
- Review Devbox overview and Blueprints
- Read Kernel’s Playwright Execution guide
