A typed Python SDK for running browser automation tasks through `browser-use`
Project description
GL Browser Use
GL Browser Use is a typed Python SDK for running browser automation tasks through browser-use. It provides a stable client facade, structured stream events, explicit result objects, optional Steel browser infrastructure, optional MinIO/S3-compatible recording storage, and bounded retries for recoverable browser-session failures.
Installation
Install the core SDK:
pip install gl-browser-use
Install optional providers only when you need them:
pip install "gl-browser-use[steel]" # Steel browser infrastructure
pip install "gl-browser-use[infrastructure]" # All browser infrastructure providers
pip install "gl-browser-use[minio]" # MinIO/S3-compatible object storage
pip install "gl-browser-use[storage]" # All object storage providers
pip install "gl-browser-use[full]" # Infrastructure + storage providers
Use the concrete extras (steel, minio) in application dependency files when you want to pin exactly which provider you depend on. The slot extras (infrastructure, storage, full) are convenience aliases and may include more providers later.
Quick Start
BrowserUseClient supports streaming and non-streaming execution. API keys can be passed directly or read from environment variables.
import asyncio
from gl_browser_use import BrowserUseClient, BrowserUseClientConfig
from gl_browser_use.infrastructure import SteelBrowserInfrastructure
from gl_browser_use.storage import MinIOS3CompatibleStorage
async def main() -> None:
client = BrowserUseClient(
config=BrowserUseClientConfig(
llm_openai_api_key="...",
page_extraction_llm_openai_api_key="...",
max_session_retries=2,
session_retry_delay_in_s=3.0,
),
infrastructure=SteelBrowserInfrastructure(), # reads STEEL_API_KEY by default
storage=MinIOS3CompatibleStorage.from_environment(),
)
async for event in client.run("Open Hacker News and list five article titles"):
print(event.content)
asyncio.run(main())
For a single aggregated result:
from gl_browser_use import BrowserUseClient, BrowserUseClientConfig
from gl_browser_use.infrastructure import SteelBrowserInfrastructure
client = BrowserUseClient(
config=BrowserUseClientConfig(
llm_openai_api_key="...",
page_extraction_llm_openai_api_key="...",
),
infrastructure=SteelBrowserInfrastructure(),
)
result = client.run_sync("Open Hacker News and list five article titles")
print(result.status)
print(result.final_output)
print(result.session_id)
print(result.streaming_url)
print(result.recording_url)
print(result.metadata)
Configuration
BrowserUseClientConfig validates required values when the client is created. If llm_openai_api_key or page_extraction_llm_openai_api_key is not passed, both default to OPENAI_API_KEY.
Common client options:
llm_openai_model: primary browser-control model. Default:o3.page_extraction_llm_openai_model: page extraction model. Default:gpt-5-mini.extend_system_message: optional system prompt extension.vision_detail_level:auto,low, orhigh. Default:auto.llm_timeout_in_s: optional LLM timeout.step_timeout_in_s: per-step browser timeout. Default:180.enable_cloud_sync: controlsbrowser-usecloud sync. Default:False.logging_level:debug,info,warning,error, orresult. Default:info.max_session_retries: recoverable session retries. Default:2.session_retry_delay_in_s: delay between retries. Default:3.0.
Optional provider environment variables:
STEEL_API_KEY: used bySteelBrowserInfrastructure()whenapi_keyis not passed.OBJECT_STORAGE_URL: MinIO/S3 endpoint, for examplelocalhost:9001orhttps://storage.example.OBJECT_STORAGE_USERNAME: object storage access key.OBJECT_STORAGE_PASSWORD: object storage secret key.OBJECT_STORAGE_BUCKET_NAME: target bucket name.OBJECT_STORAGE_DIRECTORY_PREFIX: optional object key prefix.OBJECT_STORAGE_SECURE:truefor HTTPS when the endpoint has no scheme.
Copy .env.example to .env for local development, then load it with your application environment manager.
Runtime API
The client exposes three run methods:
run(task): async generator that yieldsBrowserUseStreamEventvalues as work progresses.run_once(task): async method that returns oneBrowserUseRunResultand includes emitted events inresult.events.run_sync(task): blocking wrapper aroundrun_once()usingasyncio.run().
Do not call run_sync() from an already running event loop. Use await run_once() or async for event in run() in async applications.
Cancelling the stream by breaking from async for or calling await stream.aclose() cancels the underlying run task. Browser sessions and infrastructure sessions are released in cleanup.
Result Contract
BrowserUseRunResult contains:
status:success,error, orcancelled.task: normalized task string.final_output: final text extracted from the underlying agent, orTask completedwhen no final text is available.session_id: infrastructure session ID when an external browser session was used.streaming_url: browser debug or streaming URL when available.recording_url: expected recording URL when recording is configured.steps: number of browser-use steps executed.error: terminal error message for error results.events: collected stream events forrun_once().metadata: attempt, retry, and recording metadata.
Recording metadata uses these statuses:
disabled: infrastructure, storage, or browser context is not available.unsupported: the selected infrastructure does not support recording.unavailable: storage is configured but not available.scheduled: a background recording upload has been scheduled.unknown: recording may have started, but the terminal error did not include enough context to determine the final state.
Streaming Contract
BrowserUseStreamEvent contains:
event_typecontentthinking_and_activity_infois_finaltool_infometadata
Important event content values:
Receive streaming URL: emitted when a browser debug or streaming URL is available.Receive recording URL: emitted when a recording URL can be resolved.Task completed: emitted for the final successful step.
Activity events encode iframe URLs in thinking_and_activity_info["data_value"] as a JSON string:
{"type": "iframe", "message": "<url>"}
Step events include serialized tool calls in tool_info["tool_calls"].
Retries And Errors
The client retries only classified recoverable browser-session failures, such as browser closure or websocket disconnect messages. Before each retry, it emits a retry status event. Retries are bounded by max_session_retries, so total attempts are max_session_retries + 1.
Non-recoverable task failures return BrowserUseRunResult(status="error"). Recoverable failures that exhaust all attempts raise BrowserUseRetryExhaustedError.
SDK error types:
BrowserUseConfigurationError: missing or invalid runtime configuration.BrowserUseDependencyError: optional provider dependency problem.BrowserUseMissingDependencyError: optional provider extra is not installed.BrowserUseExecutionError: execution-time failure.BrowserUseRetryExhaustedError: recoverable session retries were exhausted.
Optional Providers
Optional providers are lazy-loaded. Importing gl_browser_use does not require Steel or MinIO to be installed.
from gl_browser_use.infrastructure import SteelBrowserInfrastructure
from gl_browser_use.storage import MinIOS3CompatibleStorage
SteelBrowserInfrastructure creates Steel browser sessions and provides CDP/streaming URLs. MinIOS3CompatibleStorage uploads session recordings to MinIO or an S3-compatible service and returns presigned URLs.
Development
From libs/gl-browser-use:
make install-dev
make test-unit
make test-integration
make lint
make build-check
Useful targets:
make test: run all tests.make test-unit: run unit tests with coverage.make test-integration: run integration-marked contract tests.make lint: run Ruff checks.make format: run Ruff fixes and formatter.make pre-commit: run pre-commit hooks.make build-check: build the package and validate artifacts with Twine.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file gl_browser_use-0.0.0b7.tar.gz.
File metadata
- Download URL: gl_browser_use-0.0.0b7.tar.gz
- Upload date:
- Size: 28.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b12e953597d3156f867e7ff0a91cf3b0b65438eb5d84b6b57b49b3a8056b63b7
|
|
| MD5 |
c4d13fd2cc790a6793e664a6638dd450
|
|
| BLAKE2b-256 |
c295cafee7ccbfcc3fc6026ac2eb4324a19e8fdc9f15f3dab4d431cad7da4205
|