On this page
praisonai-browser Package
Standalone Tier-2 package for AI browser automation: install, CLI, and imports
praisonai-browser is the standalone package that powers AI browser automation — the bridge server, CDP agent, and Playwright engine — usable on its own or inside the full praisonai stack.
from praisonaiagents import Agent
agent = Agent(name="browser-agent", instructions="Browse the web and complete tasks in Chrome.")
agent.start("Go to google and search praisonai, then summarise the top result.")The agent states a goal; praisonai-browser drives Chrome until the task completes.
graph LR
Protocol[📋 praisonaiagents<br/>protocol types] --> Browser[⚙️ praisonai-browser<br/>implementation]
Browser --> Wrapper[🤖 praisonai<br/>wrapper / shim]
Browser --> Done[✅ Task complete]
classDef proto fill:#6366F1,stroke:#7C90A0,color:#fff
classDef impl fill:#189AB4,stroke:#7C90A0,color:#fff
classDef wrap fill:#8B0000,stroke:#7C90A0,color:#fff
classDef ok fill:#10B981,stroke:#7C90A0,color:#fff
class Protocol proto
class Browser impl
class Wrapper wrap
class Done okQuick Start#
- Install the package
bash pip install praisonai-browser - Install a browser engine (once)
bash playwright install chromium # or all engines: playwright install # Docker / CI (adds OS-level deps): playwright install chromium --with-deps - Run a goal from the CLI
bash praisonai-browser run "Go to google and search praisonai" - Or use the Python API
python from praisonai_browser import BrowserServer server = BrowserServer(port=8765, model="gpt-4o") server.start() # Blocks until Ctrl+C / SIGTERM; connect the Chrome extension to it
Install#
Pick the extras you need — core alone covers the CLI and CDP agent.
pip install praisonai-browser # core
pip install "praisonai-browser[server]" # FastAPI bridge server
pip install "praisonai-browser[playwright]" # cross-browser Playwright engine
pip install "praisonai-browser[all]" # everything| Extra | Adds | Use it for |
|---|---|---|
| _(none)_ | rich, typer, click | Core CLI and CDP agent |
server | fastapi, uvicorn, websockets, aiohttp | Bridge server + Chrome extension |
playwright | playwright | Firefox/WebKit and headless runs |
all | Everything above | Full feature set |
Console Entry Point#
The package ships a praisonai-browser console script that mirrors the praisonai browser subcommands.
praisonai-browser --help
praisonai-browser run "Go to google and search praisonai"
praisonai-browser doctorInside the full stack the same commands are available as praisonai browser ….
praisonai-browser run inherits the same engine-option matrix as the wrapper — the standalone entry point mirrors praisonai browser run exactly, including which flags reach the wire on each engine and the “Ignored on the … engine” warnings.
Python API#
Import the public classes straight from praisonai_browser.
from praisonai_browser import (
BrowserServer,
BrowserAgent,
SessionManager,
CDPBrowserAgent,
run_cdp_only,
run_hybrid,
)| Export | What it does |
|---|---|
BrowserServer | FastAPI + WebSocket bridge for the Chrome extension |
BrowserAgent | Decides the next action from a page observation |
SessionManager | SQLite-backed session and step history |
CDPBrowserAgent | Drives Chrome directly over CDP (no extension) |
run_cdp_only | One-call CDP automation runner |
run_hybrid | Auto-selects Extension, CDP, or Playwright — see Hybrid runner |
Hybrid runner: engine fallback chain#
run_hybrid tries three engines in order — Extension, CDP, Playwright — and returns as soon as one runs.
graph TB
Start[🎯 run_hybrid called] --> CheckExt{🔌 Extension bridge<br/>on :8765?}
CheckExt -->|Yes| Ext[🧩 Extension engine]
CheckExt -->|No| CheckCDP{🧭 Chrome CDP<br/>on :9222?}
Ext -->|Success| Done[✅ Return result<br/>engine=extension]
Ext -->|Error| CheckCDP
CheckCDP -->|Yes| CDP[🖥️ CDP engine]
CheckCDP -->|No| CheckPW{📦 playwright<br/>importable?}
CDP --> DoneCDP[✅ Return result<br/>engine=cdp]
CheckPW -->|Yes| PW[🎭 Playwright headless]
CheckPW -->|No| Fail[❌ success=False<br/>engine=None]
PW --> DonePW[✅ Return result<br/>engine=playwright]
classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
classDef check fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef engine fill:#189AB4,stroke:#7C90A0,color:#fff
classDef done fill:#10B981,stroke:#7C90A0,color:#fff
classDef fail fill:#8B0000,stroke:#7C90A0,color:#fff
class Start input
class CheckExt,CheckCDP,CheckPW check
class Ext,CDP,PW engine
class Done,DoneCDP,DonePW done
class Fail failimport asyncio
from praisonai_browser import run_hybrid
async def main():
result = await run_hybrid(
"Search for PraisonAI on Google and open the first result",
url="https://www.google.com",
verbose=True,
)
print(result["engine"], result["success"])
asyncio.run(main())| Parameter | Type | Default | Description |
|---|---|---|---|
goal | str | (required) | Task to accomplish in natural language |
url | str | "https://www.google.com" | Starting URL |
model | str | "gpt-4o-mini" | LLM used to plan each step |
max_steps | int | 15 | Maximum automation steps |
verbose | bool | False | Log engine availability and the selected engine; CDP and Playwright also log per-step actions |
prefer_extension | bool | True | Set False to skip the extension probe and start with CDP |
The returned dict always includes:
engine—"extension","cdp","playwright", orNonewhen no engine is available.success—bool.error— present when no engine is available; tells you to start Chrome with--remote-debugging-port=9222or run the extension bridge server.
Additional fields (summary, steps) depend on the selected engine.
SessionManager custom db_path#
SessionManager stores session and step history in SQLite at ~/.praisonai/browser_sessions.db by default. Pass db_path to use a custom location — parent directories are auto-created.
from praisonai_browser import SessionManager
sm = SessionManager(db_path="/tmp/scratch/nested/subdir/browser.sqlite")Protocol Types#
The lightweight type definitions live in the agents tier and are shared across engines.
from praisonaiagents.tools.protocols.browser import (
BrowserAction,
BrowserActionType,
BrowserObservation,
BrowserSession,
)BrowserActionType includes click, type, scroll, navigate, wait, screenshot, evaluate, submit, clear_input, and done.
Backward Compatibility#
Everything from the pre-extraction layout keeps working.
| Old usage | Still works | Canonical form |
|---|---|---|
from praisonai.browser import BrowserServer, BrowserAgent | ✅ | from praisonai_browser import BrowserServer, BrowserAgent |
from praisonai.browser.sessions import SessionManager | ✅ | from praisonai_browser import SessionManager |
praisonai browser run "…" | ✅ | praisonai-browser run "…" |
python -m praisonai.browser.server | ✅ | praisonai-browser start |
Best Practices#
Install only the extras you use
Core covers the CLI and CDP agent. Add [server] for the Chrome extension bridge and [playwright] for Firefox/WebKit or headless runs.
Prefer the canonical import
Import from praisonai_browser in new code. The praisonai.browser shim stays for existing scripts.
Use the standalone CLI in slim environments
praisonai-browser runs without the full wrapper, keeping browser-only images small.
Run doctor before your first session
praisonai-browser doctor checks the server, Chrome debugging, extension, and session database in one pass.