Skip to main content
The official TypeScript client for pre.dev. predev-api ships both the Architect and Browser Agents surfaces — one package, one key, full type support.

Installation

Quick Start

Authentication

Get your API key

Grab a key from the Browser Agents dashboard.

API Methods

browserAgent()

Submit one or more browser tasks. Overloaded based on stream:
Parameters:
  • tasks (required): BrowserTask[] — see Task shape
  • options.concurrency (optional): number — parallel workers (1–20, default 5)
  • options.async (optional): boolean — return immediately with a batch id; poll with getBrowserAgent()
  • options.stream (optional): true — return an async generator of SSE frames instead

Task shape

getBrowserAgent()

Fetch the status and results of a task submission by id. Works for in-progress and completed submissions.
Parameters:
  • id (required): string — id returned from browserAgent(tasks, { async: true }) or from streaming
  • options.includeEvents (optional): boolean — include the full per-step event timeline (navigation, plan, screenshot, action, validation). Payloads can be large.

listBrowserAgents()

List your past and in-progress runs, newest first.

browserAgentStatus()

Your live queue snapshot — running / queued counts and your plan’s in-flight cap. Poll it to throttle a large submit loop.

Response Types

Streaming Events

Examples

Sync — wait for every task

Async — poll for completion

Streaming — live per-step events

Full timeline for a past submission

Error Handling

The SDK throws typed exceptions for the most common gating cases. The two billing-gate exceptions carry an actionUrl — a deep link back to pre.dev that auto-opens the right modal (subscribe / buy credits) when the user lands there. Same exceptions fire on REST and SSE error paths.
Mid-stream errors on the SSE stream throw the same typed exceptions — a for await loop wrapped in try/catch is enough.