Python Capabilities
Current client, session, context, extension, download, CDP, error, and logging APIs.
Client and regions
from lexmount import Lexmount
client = Lexmount(
region="<region-id>",
timeout=60.0,
)
print(client.region_info())
print(client.catalog_info())The client reads credentials from constructor arguments or environment variables. Region catalog discovery is best effort: an unavailable catalog or probe falls back to the configured base URL.
Sessions
Create options
session = client.sessions.create(
browser_mode="normal",
window_size="1920,1080",
downloads={"enabled": True},
recording={"persistent": True},
)| Option | Purpose |
|---|---|
browser_mode | normal for Chromium or light for Moli |
context / context_description | Reuse or create persistent browser state |
extension_ids | Mount uploaded extensions |
proxy / official_proxy | Select a custom upstream proxy or the Lexmount proxy pool |
downloads | Enable or disable stored session downloads |
recording | Enable or disable persistent replay; forced off for Moli |
custom_image_id | Start an approved custom browser image |
window_size | Set ACE browser size as width,height |
enable_lightmount_layout | Enable the LightMount layout integration; defaults to True |
enable_lightmount_resource | Override layout-resource integration for this session |
async_create | Use async create and wait for active; defaults to True |
poll_interval_sec / poll_timeout_sec | Control activation polling |
official_proxy=True and proxy={...} are mutually exclusive. Plan capabilities determine whether contexts, extensions, proxies, and custom images are available.
Read, list, targets, and close
current = client.sessions.get(session.id)
sessions = client.sessions.list(status="active")
print(sessions.pagination.total_count)
for item in sessions:
print(item.id, item.status, item.region_id, item.browser_type)
for target in client.sessions.list_targets(session.id):
print(target.title, target.url, target.inspect_url)
session.close()
# Equivalent when only the ID is available:
client.sessions.delete(session_id=session.id)Downloads
result = client.sessions.downloads.list(session.id)
print(result.summary["count"], result.summary["total_size"])
file_bytes = client.sessions.downloads.get(session.id, "<download-id>")
archive_bytes = client.sessions.downloads.archive(session.id)
deleted = client.sessions.downloads.delete(session.id)
print(deleted.deleted_count)Stored downloads are enabled by default. Configure the remote browser download path as shown in the quickstart repository so files reach the persistent download directory.
Contexts
context = client.contexts.create(
description="Authenticated storefront",
metadata={"owner": "agent-a"},
)
session = client.sessions.create(
context={"id": context.id, "mode": "read_write"},
)
contexts = client.contexts.list(status="available", limit=20)
details = client.contexts.get(context.id)
forked = client.contexts.fork(context.id)
client.contexts.force_release(context.id)
client.contexts.delete(forked.id)A context used by an active read-write session is locked. Current fork behavior copies an offline available context; hot fork, copy-on-write, and lineage tracking are not supported.
Extensions
extension = client.extensions.upload(
"/absolute/path/to/extension.zip",
name="demo-extension",
)
extensions = client.extensions.list(limit=20, offset=0)
details = client.extensions.get(extension.id)
session = client.sessions.create(extension_ids=[extension.id])
session.close()
client.extensions.delete(extension.id)The service accepts .zip and .crx archives. An extension cannot be deleted while an active session uses it.
CDP helpers and integrated authentication
from lexmount import Lexmount, connect_over_cdp
client = Lexmount()
session = client.sessions.create()
cdp = connect_over_cdp(session)
print(cdp.send("Browser.getVersion"))
cdp.close()
session.close()
client.close()The SDK also exports register_integrated_auth_callback. NTLM and Kerberos callback factories are available from the optional lexmount-extra package.
Errors and logs
from lexmount import (
APIError,
AuthenticationError,
ContextLockedError,
NetworkError,
TimeoutError,
set_log_level,
)
set_log_level("INFO")
try:
session = client.sessions.create()
except AuthenticationError:
print("Check API Key and Project ID")
except ContextLockedError as error:
print(error.active_session_id, error.retry_after)
except (NetworkError, TimeoutError):
print("Retry only after checking whether a session was reserved")
except APIError as error:
print(error.status_code)Opt-in quality reporting
Quality reporting is disabled by default and never changes user-facing errors. Enable it only when the project has approved telemetry collection:
LEXMOUNT_QUALITY_REPORTING_ENABLED=true
LEXMOUNT_QUALITY_CDP_SLOW_THRESHOLD_MS=3000Session create failures and summaries can be reported by the SDK. Individual CDP latency events are available only when commands use the SDK connect_over_cdp() helper.
Lexmount Browser