Skip to main content
Use the CLI to prove a browser-agent task. Use the SDK when that task becomes part of your product. SDK web.agent() takes explicit model config. CLI model profiles are useful for proving a task, but SDK code should pass the route, model, and credential env-var values it needs.
import { Web } from "@webcompute/sdk";

const web = new Web();

const agent = web.agent({
  model: {
    route: "openrouter",
    model: "openai/gpt-5.4-mini",
    apiKeyEnv: "OPENROUTER_API_KEY",
  },
  browser: {
    policy: { allowedDomains: ["sec.gov"] },
  },
  approval: "ask",
});

const result = await agent.run({
  startUrl: "https://www.sec.gov/edgar/search/",
  goal: "Find Apple's latest 10-Q filings and return filing metadata.",
});

console.log(result.text);

What changes when you move to the SDK

The CLI is best for first runs and operator tasks. The SDK is best when your application owns the workflow around the browser agent:
  • Load customer or job context.
  • Choose the target site and allowed domains.
  • Provide secrets through scoped variables.
  • Ask for structured output.
  • Stream progress to your UI.
  • Validate and persist the result.
  • Open the run when something looks wrong.

Production shape

Most production workflows have four parts:
  1. Deterministic setup: read database state, build a safe query, choose policy, and set budgets.
  2. Agent browsing: let the browser agent handle the web task.
  3. Deterministic validation: check schema, business rules, and source URLs.
  4. Evidence and failure handling: store artifacts, inspect status, and return blockers clearly.

Where deterministic browser control fits

Use deterministic browser control when a step must be exact: checking an expected page, downloading a known file, validating a selector, replaying a recovery path, or attaching another browser framework. It is an advanced workflow tool, not the fastest first run.

Run tasks with web agent

Prove delegated browser tasks from the terminal before embedding them in code.

SDK quickstart

Run your first web.agent() workflow in TypeScript.

Structured output

Return data your product can validate and store.

Policies and approvals

Constrain domains and handle high-impact actions.

Mix agent and code

Combine browser agents with deterministic product logic.