Skip to main content

Pydantic AI Toolsets for browser use

Project description

pai-browser-use

Release Build status codecov Commit activity License

⚠️ Early Stage Project This project is currently in early development. APIs and features may change. We welcome your feedback and contributions!

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

pai_browser_use-0.2.0.tar.gz (176.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pai_browser_use-0.2.0-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

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

Hashes for pai_browser_use-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c31b7f54150c3394550c6822b0284817a42bdc412104e415629f4208d04efef1
MD5 5908baf3bb44a3d448ee9c67a63dc024
BLAKE2b-256 20260eac623f132502a072e8623208a37a0436323c881e9d057bba4d7dc39ca7

See more details on using hashes here.

File details

Details for the file pai_browser_use-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pai_browser_use-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4767f768418cb3e5d08735b883a8a11a617226fe9ad1e83d00018f8d542a0efc
MD5 a08e45638b52751d224492cbb86155b6
BLAKE2b-256 1c3d232c5551ca365be6afeb96967a69401e3dbf2193dc3180eb5604a6bc71a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page