Browser library integration

Twin Browser + Playwright

Playwright is a browser automation library that drives Chromium, Firefox and WebKit with explicit, imperative commands — click this selector, fill that field, assert this text. It is precise and fast, and every selector is hand-written and brittle to page changes.

Browser library4-step setupBearer key auth

How Twin plugs into Playwright

Twin sits one level above Playwright-style scripting: instead of authoring and maintaining selectors, you hand it a goal and it compiles the page into a token-efficient indexed state, plans the actions, and executes them. The successful path is frozen into a skill that replays deterministically — the repeatability of a recorded script without the hand-keyed selectors, and without re-planning each time. Keep Playwright where you want full manual control; reach for Twin where a goal should survive a redesign.

Twin is the browser execution layer your stack calls. The first run cold-compiles a skill via skill compilation; every similar request after that is matched from the cache and replayed deterministically, so your marginal cost per run trends toward zero rather than climbing with usage.

app.example.com
  1. Receive goal from Playwrightdone
  2. Compile DOM → token-efficient indexed statedone
  3. Match the semantic dispatch cacherunning
  4. Replay compiled skill — 0 LLM callsqueued

Wire it up

Drop Twin into Playwright.

Copy, paste, and swap in your Bearer key. The first run compiles a skill; repeats match the semantic dispatch cache and replay deterministically.

Playwright vs Twin — the same taskpython
# Playwright: explicit selectors you maintain by hand
page.goto("https://app.acme.com/login")
page.fill("#email", user)
page.fill("#password", pw)
page.click("button[type=submit]")
page.click("text=Download invoice")

# Twin: a goal that compiles into a replayable skill
requests.post(
    "https://twin-browser.com/api/v1/run",
    headers={"Authorization": f"Bearer {os.environ['TWIN_API_KEY']}"},
    json={
        "url": "https://app.acme.com/login",
        "prompt": "Sign in and download the latest invoice",
        "success": {"kind": "textVisible", "value": "Invoice"},
    },
)
# then POST /api/v1/skills once, and replay by name with no model in the loop

Base URL https://twin-browser.com/api/v1 · auth Authorization: Bearer ab_live_… · over MCP the same engine is run_goal, compile_skill and run_skill — the full tool table.

  1. Pick the layer

    Decide which flows want explicit selectors (Playwright) and which want a goal (Twin).

  2. Send a goal

    POST { url, prompt, success } to /api/v1/run instead of scripting each step.

  3. Compile a skill

    POST /api/v1/skills to freeze the successful run so future executions skip the planning.

  4. Replay deterministically

    POST /api/v1/skills/{name}/run for a fast, selector-free replay with no model in the loop.

FAQ

Playwright on Twin — common questions

Is Twin built on Playwright?
Twin is a higher-level execution layer that runs over Playwright-class browser infrastructure. The difference is the skill layer above the driver — goal compilation, a semantic dispatch cache, deterministic replay, a credential vault and a human-in-the-loop handoff.
When should I keep using Playwright directly?
When the target is stable and you want exact control over a small set of selectors. Reach for Twin when tasks are authenticated, varied or re-phrased often enough that writing and maintaining scripts costs more than the runs do — and see the full comparison for where each one genuinely wins.

Wire up Playwright in minutes.

Free to start. Usage-based credits from $29/mo — each call billed the higher of its flat action price or its metered cost.