Skip to main content

Minimal cloud browser SDK for AgentBay (Alibaba Cloud Wuying) — session lifecycle management via CDP.

Project description

agentbay-lite

PyPI version Python License: MIT

Minimal cloud browser SDK for AgentBay (Alibaba Cloud Wuying) — session lifecycle management via CDP.

  • Lightweight: only httpx + pydantic, no Alibaba Cloud SDK dependency
  • Sync & Async: AgentBayCloud and AsyncAgentBayCloud clients
  • Context manager: sessions auto-delete on exit
  • Unified interface: same API shape as browser-use-lite, skyvern-lite, airtop-lite

Install

pip install agentbay-lite

Quick Start

from agentbay_lite import AgentBayCloud

client = AgentBayCloud(api_key="...")  # or set AGENTBAY_API_KEY env var

# Create a cloud browser session (3-step RPC: CreateMcpSession -> InitBrowser -> GetCdpLink)
session = client.sessions.create()
print(session.cdp_url)   # wss://...
print(session.session_id)

# Use with Playwright (or any CDP client)
from playwright.sync_api import sync_playwright
with sync_playwright() as pw:
    browser = pw.chromium.connect_over_cdp(session.cdp_url)
    page = browser.contexts[0].new_page()
    page.goto("https://example.com")

# Cleanup
client.sessions.delete(session.session_id)
client.close()

Context Manager

with AgentBayCloud(api_key="...") as client:
    with client.sessions.create() as session:
        ...  # session auto-deleted on exit

Async

import asyncio
from agentbay_lite import AsyncAgentBayCloud

async def main():
    async with AsyncAgentBayCloud(api_key="...") as client:
        session = await client.sessions.create()
        print(session.cdp_url)
        await client.sessions.delete(session.session_id)

asyncio.run(main())

Features

Feature Usage
Stealth mode create(browser_mode="stealth")
Custom proxy create(proxy=ProxyConfig(server="http://..."))
Managed proxy create(proxy=ManagedProxyConfig(country="US"))
Fingerprint create(fingerprint=FingerprintConfig(user_agent="..."))
Context persistence create(context=ContextAttach(context_id="..."))
Recording control create(recording=RecordingConfig(enabled=False))
Custom image create(image_id="img-xxx")
Session labels create(labels={"env": "prod"})
Idle timeout create(idle_release_timeout=300)

Session CRUD

# Create
session = client.sessions.create()

# Get
info = client.sessions.get(session.session_id)

# List
sessions = client.sessions.list(status="RUNNING")

# Delete (idempotent)
client.sessions.delete(session.session_id)

Configuration

Environment Variable Description Default
AGENTBAY_API_KEY API key (required if not passed explicitly)
AGENTBAY_ENDPOINT API endpoint hostname wuyingai.cn-shanghai.aliyuncs.com

Exception Hierarchy

CloudBrowserError          # Base exception
├── AuthenticationError    # 401/403 — invalid or expired API key
├── QuotaExceededError     # 429 — rate limit (has .retry_after attribute)
├── SessionNotFoundError   # 404 — session doesn't exist
├── ProviderError          # 5xx — server error (has .status_code, .request_id)
├── TimeoutError           # Operation timed out
└── NetworkError           # Connection failure

License

MIT

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

agentbay_lite-1.0.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

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

agentbay_lite-1.0.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file agentbay_lite-1.0.0.tar.gz.

File metadata

  • Download URL: agentbay_lite-1.0.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for agentbay_lite-1.0.0.tar.gz
Algorithm Hash digest
SHA256 804cff8107b9a54f455032da421ea2177f30859f85e71fa63862c60e236e20ce
MD5 d46a29ce15c4a9ca27b28dc309aa29c7
BLAKE2b-256 1c17f392ee66beaa465544559802f48fd44738bce6f9d3c732d607ecb6df86ad

See more details on using hashes here.

File details

Details for the file agentbay_lite-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: agentbay_lite-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for agentbay_lite-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b1d316fc146b9139463e9ef73c6e6e8e308f553c0e673a8fb0ebcea0b43340a
MD5 5b0fbd263f38a49817496151fdbd4599
BLAKE2b-256 396e11b00848d12124a50a2134841cc577760ad85e97f0b7769a53d749a5b3df

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