Docs
Dashboard
Examples / AI agentsBeta

Computer use

The agent drives the browser the way a person does, from screenshots with the mouse and keyboard (the model provider's own computer-use tool), instead of reading the page's structure.

When to use it: A page is hard to read as elements (a canvas, an unusual widget), or you want to compare the two ways.

Usesagent.run with mode: "computer", agent.models (supportsComputerUse), agent.stream
Needsa model with a computer-use tool on the API (Claude Opus 5.5, Sonnet 5.5, Haiku 5.5; GPT-6 Sol, Astra, Luna)
Sitebooks.toscrape.com (a demo shop)
Outputoutput/result.json with the answer and every screen action
LanguagesNode and Python

The code

The example as it is in its folder. Both versions do the same job and write the same output/, so one result check covers both.

/** * Computer use: the agent drives the browser the way a person does, from screenshots with the mouse and keyboard * (the model provider's own computer-use tool), instead of reading the page's structure. * *   npx tsx node/index.ts            (BOXLINE_API_KEY; TASK for your own task) * * Writes output/result.json with the answer and the actions the model took. */import { mkdirSync, writeFileSync } from "node:fs";import { join } from "node:path";import { Boxline } from "@boxline/sdk";const out = process.env.OUTPUT_DIR ?? "output";const task = process.env.TASK ?? "On https://books.toscrape.com, open the Poetry category and tell me the title and price of the cheapest book in it.";const bx = new Boxline();// A model with a computer-use tool: the configured default when it has one, else the first that does.const catalog = await bx.agent.models();const choices = catalog.providers.filter((p) => p.available).flatMap((p) => p.models.filter((m) => m.supportsComputerUse).map((m) => ({ provider: p.id, model: m.id })));const pick = choices.find((c) => c.provider === catalog.default.provider && c.model === catalog.default.model) ?? choices[0];if (!pick) throw new Error("no configured model has a computer-use tool (see bx.agent.models())");const run = await bx.agent.run({ task, mode: "computer", provider: pick.provider, model: pick.model, maxSteps: 40 });console.log(`Agent run ${run.id} (${run.provider}/${run.model}, computer mode) · Session: ${run.sessionId}`);for await (const e of bx.agent.stream(run.id)) {  if (e.type === "thought") console.log(`  ${e.text}`);  else if (e.type === "tool") console.log(`→ ${e.name} ${JSON.stringify(e.input ?? {}).slice(0, 110)}`);  else if (e.type === "done") console.log(`\n${e.status}: ${e.result ?? e.error}`);}const done = await bx.agent.get(run.id);const actions = done.steps.filter((s) => s.type === "tool" && s.name === "computer").map((s) => s.input);mkdirSync(out, { recursive: true });writeFileSync(  join(out, "result.json"),  JSON.stringify({ task, mode: done.mode, model: done.model, status: done.status, answer: done.result, computerActions: actions.length, actions, agentRuns: [{ id: run.id }], costUsd: done.usage.costUsd }, null, 2),);

Inputs

Environment variables the example reads:

  • TASK: your own task (it starts on a blank page: name the site).

Run it

Get the examples with git clone https://github.com/Boxline-dev/examples.git and open this one: cd examples/computer-use. Put your API key in BOXLINE_API_KEY (and BOXLINE_API_URL for another API), then run either version from the example’s folder. Both write to output/ and stop their sessions when they finish.

# Node 18 or newer, in the example's folderexport BOXLINE_API_KEY=…   # your API keynpm install @boxline/sdk tsxnpx tsx node/index.ts

Then check the result, from the same folder: npx tsx check.ts output. It exits with 0 only when the result is right.

What its check proves

check.ts reads what the example wrote and passes only when the result is right, not merely when the example ran.

The run used the computer tool and found the cheapest Poetry book, checked against the shop's own page.

Source

github.com/Boxline-dev/examples/computer-use on GitHub, with its README.md, check.ts and .env.example. The examples are open source. See all examples.

These docs describe a beta API. Endpoints, fields and SDK methods may change before general availability; breaking changes will be listed in the changelog.