Official TypeScript and Python SDKs for the Browser Use cloud API. Published as browser-use-sdk on npm and PyPI.
browser-use-node/src/ # TypeScript SDK
index.ts # default = v2
v3.ts # subpath = v3
v4.ts # subpath = v4
core/ # shared http + errors
generated/v{2,3,4}/types.ts # openapi-typescript output
v2/ # client + resource files + helpers
v3/ # client + sessions + helpers
v4/ # client + resource files + polling helpers
browser-use-python/src/browser_use_sdk/ # Python SDK
__init__.py # default = v2
_core/ # shared http + errors
generated/v{2,3,4}/models.py # datamodel-codegen output
v2/ # client + resource files + helpers
v3/ # client + sessions + helpers
v4/ # client + resource files + polling helpers
snapshots/v{2,3,4}.json # last-generated OpenAPI specs
Taskfile.yml # mechanical commands
RUNBOOK.md # /sdk pipeline guide + learnings
.env # CLOUD_REPO_PATH, BACKEND_URL, BROWSER_USE_API_KEY
- v2 (default) — stable, full API surface.
import { BrowserUse } from "browser-use-sdk"/from browser_use_sdk import BrowserUse - v3 — subpath import.
import { BrowserUse } from "browser-use-sdk/v3"/from browser_use_sdk.v3 import BrowserUse - v4 — current API, subpath import.
import { BrowserUse } from "browser-use-sdk/v4"/from browser_use_sdk.v4 import BrowserUse
Run /sdk to update both SDKs from the OpenAPI specs. See RUNBOOK.md for the pipeline phases and accumulated learnings.
task gen:types # generate TS + Python types from OpenAPI
task check # type-check both SDKs
task build # compile both SDKs
task test # spec-driven vibe tests (no backend)
task test:live # live integration tests (needs backend)
task snapshot:save # save current specs as snapshots
task version:bump # bump package versions
task publish # npm + pypi publish- 1:1 with OpenAPI. Every endpoint maps to an SDK method.
- Types are generated.
openapi-typescript+datamodel-codegen. Deterministic. - Helpers are minimal.
complete()andstream()are ~20 lines each. - Python returns Pydantic models. Full type safety, not dicts.
- Everything is regeneratable. Generate, audit, fix, ship.
- Every method with a request body MUST accept
**extra(Python) or spread extra fields (TS) for forward-compatibility. No exceptions. - Both SDKs must stay in sync. Same retry logic, same polling defaults (2s interval, 300s timeout), same terminal statuses, same backoff cap (10s). When changing behavior in one SDK, change both.
- Retry HTTP 429 for all methods, and 502/503/504 for GET only. Honor integer-second
Retry-Afterwithin the existing ten-second delay cap; surface longer waits and use normal backoff for other formats. Keep the retry count and up to 250ms jitter; timeout remains per attempt. Do not retry other 5xx. - Transport retries: GET only. Retry network failures (refused/reset connections, DNS, connect timeout, a body cut off mid-read). Never retry other methods (a write may have reached the server), x402 or a custom fetch (may pay per request), read timeouts (they multiply the caller's timeout), TLS certificate failures or client-side errors. Never follow redirects.
- Every public method needs a docstring (Python) or JSDoc (TS). One-liner, imperative style.
- Re-export all user-facing types from top-level
__init__.py/index.ts. Users should never need to import fromgenerated/directly. - Busy 503 exception.
request_idempotent/requestIdempotentretry a 503 carryingRetry-After(capped at 10s). Use them only for idempotent calls the server marks busy, such as run cancel and session delete.
- Never use
Dict[str, Any]for typed params. If the OpenAPI spec defines a schema, use the generated Pydantic model (e.g.SessionSettings,CustomProxy). Only useDict[str, Any]when the spec literally saysobjectwith no further schema. - Use
X | None, notOptional[X]. Modern Python union syntax everywhere — hand-written code and generated code (via--use-union-operatorflag). - No
Optional,Dict,List,Unionimports fromtypingin hand-written code. Use built-indict,list,X | Ysyntax (withfrom __future__ import annotations).