Skip to main content
Boat gives an agent a full Ubuntu machine in the cloud: root, Docker, SSH and coding agents already installed, billed per second. This guide runs agent code in a Boat sandbox and gives it a real browser on Anchor. Every sample is in Python and TypeScript. Tested with the Boat SDKs 1.15.0 (boat-sdk and @boatdev/sdk), the Anchor Python SDK 1.0.1 and the Anchor TypeScript SDK 1.0.0.

What you’re integrating

Anchor SDK in a Boat sandbox → Anchor Cloud. The sandbox runs your agent and its code. Chromium runs as a managed Anchor cloud session, reached over HTTPS and CDP.
  • Boat stays the code runtime: the agent edits files, installs packages and runs commands there.
  • Anchor stays the remote browser: stealth, proxies, live view and session lifecycle.
  • The sandbox can be locked so its only way out is Anchor.
A Boat sandbox also ships Chrome and a desktop of its own. That browser runs inside the sandbox, on the sandbox’s address, and needs the sandbox’s network open to every site it visits. With Anchor the browser is outside the sandbox: it gets past bot detection, you watch it through Anchor’s live view, and the sandbox itself only needs to reach two Anchor hosts.

Before you start

Sign up at boat.dev and create an API key in the dashboard. Keep it in your shell:
Install the Boat SDK for your language:
The TypeScript samples use top-level await, so set "type": "module" in your package.json.

Store your Anchor key in Boat

Create an Anchor key at API Keys. Save it as a variable of your default Boat environment, so every new sandbox starts with it and it never sits in your code. With the key in ANCHORBROWSER_API_KEY in your shell:
The value goes in the request body, read from standard input, so it does not appear in the process list. Keep the name ANCHORBROWSER_API_KEY: the Anchor Python SDK reads it on its own, and the TypeScript samples pass it to the SDK.
Boat puts the real key inside the sandbox as an environment variable, and anything that runs there can read it. Use a dedicated Anchor key for sandboxes, and lock the sandbox so the key has nowhere else to go.

Run a web task from the sandbox

Describe the goal in plain English and let Anchor’s agent drive the browser. The script creates a sandbox, installs the Anchor SDK, runs the task and deletes the sandbox.
Both print:
What the script relies on:
  • The sandbox is ready in seconds. In testing a small sandbox was ready 2.6 seconds after the create call, and the Python script ran end to end in 33 seconds, install included.
  • The install is small. playwright (Python) and playwright-core (Node.js) are only the client library that speaks CDP. You do not run playwright install, because the browser lives on Anchor. Python needs a virtual environment: Ubuntu’s system pip refuses to install packages outside one.
  • Paths are relative to /home/user. write_text and exec_command both start there. The TypeScript version runs in the anchor folder, where npm installed the packages.
  • The session is created first. The task runs on a session the script created, so finally can always end it, also when the task fails.

Drive the browser yourself with Playwright

For step-by-step control, create an Anchor session and connect Playwright to it over CDP from inside the sandbox.
Both print:
session.data.cdp_url and the live view URL carry a session token (rt). Anyone who has one of them can reach that browser until the session ends. Do not write them to logs you share.

Watch the browser

Open the live view URL in your own browser while the script runs, or open the session in the Anchor dashboard. This is the Anchor session streaming directly, so the sandbox needs no desktop, tunnel or public port for it.
Anchor dashboard showing a running session with the live browser on Books to Scrape, opened by a script inside a Boat sandbox
The Boat dashboard shows the other half: the sandbox that runs your script.
Boat dashboard listing one running small sandbox with 2 vCPU and 4 GB
Its metrics list the Playwright driver from anchor-env as a process using about 109 MB. No browser runs in the sandbox for this work, because the browser is on Anchor.
Boat sandbox metrics with CPU, RAM, disk and IO, and the Playwright driver from anchor-env in the process list

Lock the sandbox to Anchor

By default a Boat sandbox can reach any public address. When the code inside is untrusted, limit it to the two hosts the Anchor SDK needs with a Boat network policy. Install the packages first, then set the policy and wait until Boat reports it as enforced:
In testing the policy was enforced within 20 seconds. The loop stops with an error after 60, so a policy that never applies does not hang the script. The Playwright script still works in that sandbox, and requests to other sites fail:
The code can still browse any site, because the page loads happen in Anchor’s browser, not in the sandbox. It just cannot open its own connections anywhere else. This is the main reason to pair the two: the agent’s code is boxed in, and all web access goes through one browser you can watch and record. live.anchorbrowser.io is opened by the person watching, not by the sandbox, so it does not need to be on the list. Boat’s own exec and file calls keep working under any policy.

Give the coding agents in the sandbox Anchor’s MCP server

Every Boat sandbox has Claude Code, Codex and other coding agents installed. Register Anchor’s hosted MCP server once and the agent can run web tasks by itself:
Run it inside the sandbox, for example with exec_command. claude mcp list then shows Anchor next to the computer server Boat registers itself:
A locked sandbox also blocks the agent’s own model provider. With only the two Anchor hosts allowed, api.anthropic.com is blocked, so Claude Code cannot reach its model. If you run a coding agent inside a locked sandbox, add the hosts that agent needs to allow. For Claude Code that includes api.anthropic.com: with it on the list, the sandbox reaches it and example.org stays blocked. The registration is stored in /home/user/.claude.json, with the key in it. See the MCP server page for the tools it offers.

Clean up two lifecycles

There are two things to end, and ending one does not end the other.
  • The Anchor session. End it in a finally block inside the sandbox script. Deleting the sandbox does not end a cloud browser; it keeps running and billing until its own timeout.
  • The Boat sandbox. Delete it in a finally block. ttl_seconds (Python) or ttlSeconds (TypeScript) stops the sandbox if your script dies before that.
  • Set Anchor’s timeout.max_duration and timeout.idle_timeout, in minutes, as a safety net for a sandbox that dies mid-run. See Session Timeout.
  • Reuse one Anchor session for a whole agent run instead of creating one per page.
To confirm nothing is left running:
Each test run on this page used a small sandbox for 8 to 20 seconds. Boat reported $0.0001 to $0.0002 per run.

API key

Each customer brings their own Anchor key as a variable of their Boat environment. Anchor bills them directly for browser usage; Boat bills for the sandbox.

Troubleshooting

  • 402 billing_required when you create a sandbox: the Boat account has no plan yet. Start one in the Boat dashboard under Billing.
  • 401 from Anchor inside the sandbox: the variable is missing or has another name. Check that your default environment holds ANCHORBROWSER_API_KEY.
  • error: externally-managed-environment from pip: Ubuntu’s system Python refuses installs outside a virtual environment. Create one with python3 -m venv anchor-env, as the samples do.
  • 403 trial_saved_snapshots_not_allowed: Boat’s free trial cannot save a sandbox as a saved snapshot, so the samples install the SDK at the start of each run. The install takes about 14 seconds.
  • 400 trial_auto_stop_required: during Boat’s free trial a sandbox needs an auto-stop of at most 2 hours. Pass ttl_seconds of 7200 or less.
  • A request fails right after you set a network policy: the policy can report pending for a moment. Wait until its status is enforced, as the sample does.
  • The command stops after 30 seconds: that is Boat’s default command timeout. Pass timeout_seconds (up to 600), as the samples do. A web task can take a few minutes.
See the Sandboxes overview and Create a Session.