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

Installation

Quick Start

Authentication

Get your API key

Grab a key from the Browser Agents dashboard.

API Methods

browser_agent()

Submit one or more browser tasks and get the results back.
Parameters:
  • tasks (required): List[Dict] — see Task shape below
  • concurrency (optional): int — parallel workers within this batch (1–20, default 5)
  • stream (optional): bool — when True, returns an iterator yielding SSE events instead of a final result
  • run_async (optional): bool — when True, returns immediately with { id, status: "processing" }; poll with get_browser_agent(id)
Returns:
  • Default: Dict with id, total, completed, results, totalCreditsUsed, status
  • With stream=True: Iterator[Dict] yielding { "event": ..., "data": ... } frames
  • With run_async=True: Dict with id and status: "processing" — poll get_browser_agent(id)

Task shape

get_browser_agent()

Fetch the status and results of a task submission by id. Works for in-progress and completed submissions.
Parameters:
  • batch_id (required): str — id returned from browser_agent(..., run_async=True) or from streaming
  • include_events (optional): bool — when True, includes the full per-step event timeline (navigation, plan, screenshot, action, validation) for each task. Payloads can be large.
Returns: Dict with the same shape as browser_agent() sync response, plus events[] on each task (or liveEvents[] for tasks still in flight) when include_events=True.

list_browser_agents()

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

browser_agent_status()

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

Response Shape

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 raises typed exceptions for the most common gating cases. The two billing-gate exceptions carry an action_url — 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 raise the same typed exceptions — a for msg in client.browser_agent(..., stream=True): loop wrapped in try/except is enough.