web.agent() takes explicit model config. CLI model profiles are useful for direct runs and operator workflows, but SDK code should pass the route, model, and credential env-var values it needs.
Choose the right workflow surface
The CLI and SDK use the same managed browser runtime, but they fit different workflow boundaries:- Use the CLI for workflows you run directly from a terminal, script, or operator process.
- Use the SDK when the workflow needs application context, user authorization, queues, schedules, product UI, or persistence.
- Use SDK browser resources when the workflow needs explicit browser lifecycle, files, downloads, recordings, status, or recovery.
- Use MCP when a coding-agent host should operate the browser.
- Use REST, CDP, quick actions, or exact browser control when those integration boundaries are the right fit.
Build the workflow around the agent
Most integrated workflows use SDK resources around the agent:Workflow shape
Most integrated workflows have four parts:- Deterministic setup: read database state, build a safe query, choose policy, and set budgets.
- Agent browsing: let the agent operate the web application inside the managed browser.
- Deterministic validation: check schema, business rules, and source URLs.
- 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. When deterministic work needs browser metadata or resources, create or fetch a browser handle and pass itsbrowserId into the agent run.
Run tasks with web agent
Run standalone agentic workflows from the terminal with model profiles, boundaries, schemas, and inspection.
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 agent-driven browser work with explicit SDK resources and product logic.