Logo of Lexmount
DocsTemplatesBlogHelp Center
GitHub
Logo of LexmountLexmount Browser

Get started

Lexmount Documentation

Browser

OverviewQuickstartCapabilitiesExamples

Web Fetch

OverviewQuick Start
Common Errors

Help and billing

Capability FAQCloud Browser Pricing and Web Fetch API Billing
ChangelogContact support
Python SDK

Python Quick Start

Create Chromium and Moli sessions and connect to Chromium with Playwright.

Prepare credentials first

Create an API Key and copy its Project ID from Settings → API Keys. You can verify the same flow in the console quick start before running code.

1. Install

Use Python 3.10 or later for these pinned Playwright dependencies.

python3 -m venv .venv
source .venv/bin/activate
pip install lexmount==0.6.1 playwright==1.63.0 python-dotenv

2. Configure credentials

export LEXMOUNT_API_KEY='<your-api-key>'
export LEXMOUNT_PROJECT_ID='<your-project-id>'

# Optional; defaults to the CN API
export LEXMOUNT_BASE_URL=https://api.lexmount.cn

Use https://api.lexmount.com for the global service. Never commit the API Key to source control.

3. Create and control Chromium

Save the following as example.py and run python example.py.

from lexmount import Lexmount
from playwright.sync_api import sync_playwright

with Lexmount() as client:
    with client.sessions.create(browser_mode="normal") as session:
        print("session:", session.id)

        with sync_playwright() as p:
            browser = p.chromium.connect_over_cdp(session.connect_url)
            context = browser.contexts[0]
            page = context.pages[0] if context.pages else context.new_page()

            page.goto("https://example.com", wait_until="domcontentloaded")
            print("title:", page.title())
            browser.close()

The context managers close the HTTP client and session even if browser code raises an exception.

4. Create Moli

Moli is the product name for the stable SDK/API value light:

from lexmount import Lexmount

with Lexmount() as client:
    with client.sessions.create(browser_mode="light") as session:
        print(session.id)

Use Moli for lightweight agent browsing and content-oriented tasks. Persistent replay is always disabled for Moli. Use Chromium when a task depends on the full persistent-browser feature set.

5. Know the defaults

BehaviorCurrent default
Session create pathAsync create, polling until active
Activation timeout600 seconds
Stored downloadsEnabled unless downloads={"enabled": False}
Chromium persistent replayEnabled by the current platform unless explicitly disabled
Moli persistent replayAlways disabled
Automatic CAPTCHA processingDisabled; opt in with enable_captcha when creating a session
RegionDefault catalog region when available; otherwise the configured base URL

Explicitly disable artifacts that the task does not need:

session = client.sessions.create(
    browser_mode="normal",
    downloads={"enabled": False},
    recording={"persistent": False},
)

To request automatic CAPTCHA processing, opt in for the new session. See automatic CAPTCHA processing for the example and plan allowance requirements.

6. Select a region

from lexmount import Lexmount

client = Lexmount(region="<region-id>")
print(client.region_info())
print(client.catalog_info())
client.close()

If catalog lookup or host probing is unavailable, the SDK falls back to LEXMOUNT_BASE_URL.

Troubleshooting

  • Authentication error: confirm the API Key and Project ID come from the same project.
  • Create timeout: inspect the exception and console session list before retrying; async create may already have reserved a session ID.
  • View works but Playwright does not connect: confirm the session is still active and that your network can reach session.connect_url.
  • Resources remain active: use nested context managers or close the session in finally.

Continue with Python Capabilities or run a script from Python Examples.

Python SDK

Create and control Lexmount browser sessions from Python.

Python Capabilities

Current client, session, context, extension, download, CDP, error, and logging APIs.

Table of Contents

1. Install
2. Configure credentials
3. Create and control Chromium
4. Create Moli
5. Know the defaults
6. Select a region
Troubleshooting

Still need help?Ask on Discord