Pydantic AI Toolsets for browser use
Project description
pai-browser-use
⚠️ Early Stage Project This project is currently in early development. APIs and features may change. We welcome your feedback and contributions!
- 🐛 Found a bug? Submit an issue
- 💡 Have ideas or suggestions? Join the discussion
- 🤝 Want to contribute? Check out our Contributing Guide
Pydantic AI Toolsets for browser automation using Chrome DevTools Protocol (CDP).
Inspired by browser-use, designed for Pydantic AI agents.
Features
- Browser Automation Tools: Navigation, state inspection, interaction, and element queries
- Multi-Modal Screenshots: Automatic image splitting for long pages with ToolReturn support
- Type-Safe CDP Integration: Direct access to cdp-use API with full type hints
- Fully Tested: Comprehensive test suite with Docker-based Chrome container
Installation
Use pip:
pip install pai-browser-use
Or use uv:
uv add pai-browser-use
Quick Start
Prerequisites
Start a Chrome instance with CDP enabled:
# Option 1: Using Chrome directly
google-chrome --remote-debugging-port=9222
# Option 2: Using Docker container
./dev/start-browser-container.sh
Basic Usage
import os
from pydantic_ai import Agent
from pai_browser_use import BrowserUseToolset
agent = Agent(
model="anthropic:claude-sonnet-4-5",
system_prompt="You are a helpful assistant.",
toolsets=[
BrowserUseToolset(cdp_url="http://localhost:9222/json/version"),
],
)
result = await agent.run("Find the number of stars of the wh1isper/pai-browser-use repo")
print(result.output)
See examples/agent.py for a complete example.
Logging
Use PAI_BROWSER_USE_LOG_LEVEL environment variable to set logging level. The default is ERROR. Set to DEBUG for more verbose logging.
Development
# Install dependencies
uv sync
# Run tests
pytest tests/
# Run example
python examples/agent.py
# Try DEBUG logging demo (shows extracted content)
PAI_BROWSER_USE_LOG_LEVEL=DEBUG python demo_debug_logging.py
License
BSD 3-Clause License - see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pai_browser_use-0.2.0.tar.gz.
File metadata
- Download URL: pai_browser_use-0.2.0.tar.gz
- Upload date:
- Size: 176.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c31b7f54150c3394550c6822b0284817a42bdc412104e415629f4208d04efef1
|
|
| MD5 |
5908baf3bb44a3d448ee9c67a63dc024
|
|
| BLAKE2b-256 |
20260eac623f132502a072e8623208a37a0436323c881e9d057bba4d7dc39ca7
|
File details
Details for the file pai_browser_use-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pai_browser_use-0.2.0-py3-none-any.whl
- Upload date:
- Size: 31.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4767f768418cb3e5d08735b883a8a11a617226fe9ad1e83d00018f8d542a0efc
|
|
| MD5 |
a08e45638b52751d224492cbb86155b6
|
|
| BLAKE2b-256 |
1c3d232c5551ca365be6afeb96967a69401e3dbf2193dc3180eb5604a6bc71a2
|