Skip to main content
InstaBox gives every agent a Linux machine of its own in the cloud, with root, Docker and coding agents already installed. This guide runs agent code on an InstaBox machine and gives it a real browser on Anchor. Every sample is in Python and TypeScript. Tested with the InstaBox CLI 0.8.497, instabox-sdk 0.5.15, @insforge/instabox-sdk 0.11.0, the Anchor Python SDK 1.0.1 and the Anchor TypeScript SDK 1.0.0.

What you’re integrating

Anchor SDK on an InstaBox machine → Anchor Cloud. The machine runs your agent and its code. Chromium runs as a managed Anchor cloud session, reached over HTTPS and CDP.
  • InstaBox 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 Anchor key is an InstaBox Org Secret. The machine holds a placeholder, and InstaBox’s outbound proxy swaps in the real key on requests to api.anchorbrowser.io.
  • A network allowlist limits the machine to Anchor’s two hosts.
An InstaBox machine also has Chromium and a desktop of its own. That browser runs on the machine, from the machine’s address, and needs the machine’s network open to every site it visits. With Anchor the browser is outside the machine: it gets past bot detection, you watch it through Anchor’s live view, and the machine itself only needs to reach Anchor.

Before you start

Install the instabox CLI and sign in by following the InstaBox quick start. Check it works:
For the SDK samples, create an API key in the InstaBox dashboard and install the SDK for your language:
The TypeScript samples use top-level await, so set "type": "module" in your package.json.

Save your Anchor key as an Org Secret

Create an Anchor key at API Keys. Save it as an Org Secret that may only go to Anchor’s API host. With the key in ANCHORBROWSER_API_KEY in your shell:
Without the pipe, the command asks for the value at a hidden prompt. Keep the name ANCHORBROWSER_API_KEY: the Anchor Python SDK reads it on its own, and the TypeScript samples pass it to the SDK.
Saving a Secret needs a signed-in owner or admin. An API key of a personal workspace is refused with 403 missing_scope and the hint sign in with instabox login, or use an API key of a workspace.

Prepare a snapshot once

Install the Anchor SDK and the Playwright client on one machine, save it as a snapshot, and start every later machine from that snapshot.
The save prints:
What to expect:
  • The machine is ready in seconds. In testing, a new machine ran 3.7 seconds after the create call. The Python install took 6 seconds and the Node.js install 4.
  • The snapshot takes a few minutes. The save took about 3.5 minutes. You do it once.
  • 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. The machine runs Debian 13, whose system pip refuses to install packages outside one.
  • The free plan runs one machine at a time. That is why the commands delete anchor-prep before the next step. The snapshot is kept.

Create a locked machine from the snapshot

Create the machine your agent works on. --secrets all gives it the workspace’s proxy Secrets, and --allow-domain limits where it can connect:
The first machine from a new snapshot took about 1 minute 50 seconds, most of it downloading the snapshot.
InstaBox dashboard listing the anchor-demo machine as Running, created from the anchor-sandbox snapshot, with 4 vCPU, 8 GiB memory and a 20 GiB disk
Check the policy and the Secret:
The InstaBox SDKs create machines, but they do not take a Secret selection or a network policy at create. Create the machine with the CLI, as above, and use the SDK to run code on it.

The key stays out of the machine

Inside the machine the variable holds a placeholder that starts with ibsec_, not your key:
Send the placeholder in Anchor’s usual header. The proxy replaces it with the real key on the way out:
So curl, the SDKs and MCP clients on the machine all authenticate without holding the key, and an agent that prints its environment or reads its config files cannot leak it. The key is not in the snapshot either. The cdp_url a session returns carries no API key. It holds a session ID and a session token, which is why connect.anchorbrowser.io needs no Secret.

Run a web task on the machine

Describe the goal in plain English and let Anchor’s agent drive the browser. The script writes a small program to the machine and runs it there.
Both print:
What the script relies on:
  • The machine wakes up by itself. An idle machine pauses after 30 minutes. ensure_running and Sandbox.connect resume it.
  • Home is /data/home. The Python SDK writes relative paths there. The TypeScript version runs in /data/home/anchor, 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.
  • Anchorbrowser() takes no key. It reads the placeholder from the environment and the proxy does the rest.

Drive the browser yourself with Playwright

For step-by-step control, create an Anchor session and connect Playwright to it over CDP from the machine.
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 machine needs no desktop, tunnel or public port for it.
Anchor dashboard showing a running session with the live browser on Books to Scrape and its network requests, opened by a script inside an InstaBox machine
The machine itself has a terminal and a desktop in the InstaBox dashboard:
InstaBox dashboard for the anchor-demo machine, with a terminal on the left and the machine's desktop on the right

What the allowlist blocks

The machine reaches Anchor and nothing else. A name that is not on the list does not resolve:
Exit code 6 is curl’s “could not resolve host”. The agent’s code can still browse any site, because the page loads happen in Anchor’s browser, not on the machine. 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 machine, so it does not need to be on the list. To install more packages later, open the network, install, and lock it again. Both changes take effect at once:

Give the coding agents on the machine Anchor’s MCP server

The default template has Claude Code, Codex and OpenCode installed. Register Anchor’s hosted MCP server once, with the placeholder in the header:
Claude Code’s config on the machine stores the placeholder, not the key. 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 script that runs on the machine. Pausing or deleting the machine does not end a cloud browser; it keeps running and billing until its own timeout.
  • The InstaBox machine. It pauses by itself after 30 idle minutes. Delete it with instabox rm --yes anchor-demo when you are done. The snapshot stays until you delete it with instabox snapshot rm anchor-sandbox --yes.
  • Set Anchor’s timeout.max_duration and timeout.idle_timeout, in minutes, as a safety net for a machine that stops mid-run. See Session Timeout.
  • Reuse one Anchor session for a whole agent run instead of creating one per page.
To confirm no browser is left running, ask Anchor from the machine:
instabox secrets show anchor-demo also counts how many requests the proxy added the key to. After the runs on this page it read 10 requests, 0 denied.

API key

Each customer brings their own Anchor key as an Org Secret of their InstaBox workspace. Anchor bills them directly for browser usage; InstaBox bills for the machine.

Troubleshooting

  • 403 missing_scope when you save the Secret: you are using an API key of a personal workspace. Sign in with instabox login and run instabox secrets set again.
  • 401 from Anchor on the machine: the machine has no Secret selected, or the Secret has another name. Run instabox secrets show anchor-demo. Create the machine with --secrets all, and save the Secret as ANCHORBROWSER_API_KEY.
  • error: externally-managed-environment from pip: Debian’s system Python refuses installs outside a virtual environment. Create one with python3 -m venv ~/anchor-env, as the setup does.
  • pip or npm cannot resolve its registry: the allowlist blocks it. Open the network, install, and lock it again, as shown in What the allowlist blocks. Better, install in the snapshot.
  • The command stops after 60 seconds: that is the default command timeout. Pass timeout (Python) or timeoutMs (TypeScript), as the samples do. A web task can take a few minutes.
See the Sandboxes overview and Create a Session.