Cookbook
Runnable browser examples grouped by use case. Each one is self-contained: paste it, run it, read the output.
Every example is a single self-contained file in the Box SDK
repo.
All of them need UPSTASH_BOX_API_KEY. Examples marked AI use metered
browser AI (run, act, extract) and need a model provider key on the box
or account. Everything else runs with the Box key alone.
Agents
Goal-driven browsing with tab.run().
Constrained search with a fallback category. The agent evaluates results, rejects with reasons, and switches on its own. AI
The same task via Playwright, act plus extract, and run. Pick your autonomy level by token cost. AI
The search again with live view, session recording, a decision log, and token accounting. AI
One prompt and one schema across three differently structured sites. AI
Automation
Forms, files, and durable sessions.
Script the deterministic steps, delegate the judgment call to a single act, and assert the result.
A download lands on the box filesystem and is processed in place.
Upload a box-generated file through a real form over CDP.
Log in once into a keep-alive box, then have any later script reuse the session.
Retrieval
Structured data out of rendered pages.
One extract call, schema-validated typed output, screenshot provenance. AI
AI compiles selectors once, then every later run scrapes deterministically. AI (first run only)
Crawl a client-rendered docs section into chunked JSONL via tab.content().
Full-page captures plus a hashed manifest, assembled in the box and downloaded as one archive.
Testing
The box as a test environment.
An existing Playwright test where only the launch line changes.
The box hosts the app under test and browses it on its own localhost.
Agent-driven smoke flow, cross-checked by deterministic DOM assertions, recorded on video. AI
Pixelmatch diffs against baselines stored on the box.