Official Python SDK for BrowseFleet, the open-source cloud browser API for AI agents.
One runtime dependency (httpx). Sync + async clients in one import. Full type hints with py.typed. Tested on Python 3.10, 3.11, 3.12, 3.13.
Working in this repo with an AI agent? Read
skill.mdfirst. It teaches Claude Code, Cursor, Aider, or any coding agent how to set up, run, test, and contribute to this repo with no further instruction.
pip install browsefleetThe SDK needs a running BrowseFleet server. Follow the server repo's Quick start to spin one up via Docker or local Node dev.
from browsefleet import BrowseFleet
bf = BrowseFleet(
base_url="http://localhost:3000", # or BROWSEFLEET_URL env var
api_key="optional-when-server-requires-it", # or BROWSEFLEET_API_KEY env var
)
# Scrape a page
page = bf.scrape("https://example.com")
print(page.title, page.markdown[:200])
# Take a screenshot
png = bf.screenshot("https://example.com", full_page=True)
with open("example.png", "wb") as f:
f.write(png)
# Generate a PDF
pdf = bf.pdf("https://example.com", format="A4", print_background=True)
# Spin up a persistent session
session = bf.sessions.create(stealth="full")
bf.sessions.actions(session.id, [
{"type": "navigate", "url": "https://example.com"},
{"type": "screenshot"},
])
bf.sessions.release(session.id)
# Vision-based agent task
result = bf.agent.run(
task="Extract the most expensive product price from this page",
url="https://example.com/products",
provider="anthropic",
max_iterations=10,
)
print(result.success, result.result)import asyncio
from browsefleet import AsyncBrowseFleet
async def main():
async with AsyncBrowseFleet(base_url="http://localhost:3000") as bf:
page = await bf.scrape("https://example.com")
print(page.title)
asyncio.run(main())Both clients share the same public surface. Same methods, same return types, same typed errors.
- Sessions, scrape, screenshot, PDF, agent, profiles, files, CAPTCHA. Full coverage of the BrowseFleet REST surface.
- Operator mode. Sessions can start in
humancontrol, hand off toagentviasessions.control(). - Typed errors.
AuthError,NotFoundError,RateLimitError,ValidationError,ServerError, all extendingBrowseFleetError. - Auto-retry. Exponential backoff on
429/5xx, honorsRetry-After. Configurable per client viamax_retries. - Env-var fallback.
BROWSEFLEET_URLandBROWSEFLEET_API_KEYare read when not passed explicitly. - Sync + async.
BrowseFleetandAsyncBrowseFleet. Both implement context-manager protocol. - Typed.
py.typedmarker, dataclass return types,TypedDictrequest params. Strict mypy across the source.
BrowseFleet(
base_url="http://localhost:3000", # or BROWSEFLEET_URL env (default: http://localhost:3000)
api_key="optional", # or BROWSEFLEET_API_KEY env (omit if server is authless)
timeout=60.0, # seconds, default 60
max_retries=2, # retries on 429 / 5xx, default 2
)See examples/ for runnable mini-projects:
examples/quickstart/, scrape + screenshot + releaseexamples/agent_task/, vision-based agent taskexamples/operator_mode/, human-to-agent handoff via profile + control state machineexamples/async_client/, the same flows onAsyncBrowseFleet
PRs welcome. Read CONTRIBUTING.md and skill.md. Conventional Commits, squash-merge, base branch is master.
Do not file security issues publicly. See SECURITY.md.
MIT. See LICENSE.