Skip to main content
Use web.agent() when an agentic workflow belongs inside an application, backend process, or recurring automation.

Prerequisites

  • Node.js 20 or newer, plus npm or another Node package manager.
  • A Webcompute API key exported as WEBCOMPUTE_API_KEY. The TypeScript SDK reads the key from this environment variable or from new Web({ apiKey }).
  • A model-provider key for the route you choose. This page uses OpenRouter, so export OPENROUTER_API_KEY.
  • A target workflow and domain boundary. If you want to run the workflow from the terminal first, start with the CLI quickstart.

Install the SDK

Version metadata is published at https://install.webcompute.dev/sdk/latest.json for pinned installs. Set your Webcompute API key:
If you used web model setup in the CLI, copy the same route, model, and credential env-var name into SDK code. SDK web.agent() requires explicit model config.

Run an agent workflow

The agent creates a managed browser, stays inside sec.gov, records the run, and returns a final result. One-shot agent runs close browsers they create when the run completes. Use long-running tasks or an explicit browser session when your application needs continuity or post-run live inspection. Use the SDK reference when you need the full surface: agent, browser, resources, quick actions, policy, and proxy. You can also pass a string when only the goal is needed:

Read the result

Use result.output when you provide an output schema. Use result.steps and result.artifacts when you need evidence for logs, review, or debugging.
Signed Debug UI and CDP URLs are bearer capabilities. Do not log them or expose them to untrusted users.

Add browser resources around the agent

Create the browser yourself when the workflow needs explicit lifecycle, recording, downloads, status, or recovery around the agent run.
Webcompute provides the managed browser runtime. SDK resources make the browser boundary, durable files, status checks, and recovery path explicit around the agent run. When you pass browserId, configure policy on web.browser.create(...). Use agent.session(...) when multiple related goals should share the same browser.
Sessions keep the same browser alive across related goals. Write follow-up goals with the context the model needs.

Next steps