Skip to main content
Beta Feature — Browser automation is currently in beta. Please report any issues to founders@morphllm.com.
Use Morph’s optimized morph-computer-use-v0 model with browser-use Python SDK to get 10x cheaper browser automation with faster inference.

Why Use This?

Morph + browser-useClaude + browser-use
Cost0.30input/0.30 input / 1.50 output per 1M tokens3.00input/3.00 input / 15.00 output per 1M tokens
Speed280 tokens/sec60 tokens/sec
OptimizationPurpose-built for browser automationGeneral-purpose reasoning
You get: browser-use’s Python interface + Morph’s pricing + faster inference.

Installation

# Install browser-use
pip install browser-use

# Install browser dependencies
playwright install

Quick Start

Morph is OpenAI-compatible, so you can use it directly with browser-use’s ChatOpenAI:
from browser_use import Agent, ChatOpenAI
import asyncio
import os

# Point to Morph API (OpenAI-compatible endpoint)
llm = ChatOpenAI(
    model="morph-computer-use-v0",
    api_key="YOUR_API_KEY",
    base_url="https://api.morphllm.com/v1"
)

agent = Agent(
    task="Go to amazon.com, search for 'laptop', and give me the title of the first result",
    llm=llm
)

async def main():
    result = await agent.run(max_steps=10)
    print(result)

asyncio.run(main())

Real-World Examples

Test product search and checkout flows:
from browser_use import Agent, ChatOpenAI
import asyncio
import os

llm = ChatOpenAI(
    model="morph-computer-use-v0",
    api_key="YOUR_API_KEY",
    base_url="https://api.morphllm.com/v1"
)

async def test_ecommerce():
    # Test search functionality
    agent = Agent(
        task=(
            "Go to amazon.com, search for 'wireless mouse', "
            "click on the first result, and tell me the price"
        ),
        llm=llm
    )
    
    result = await agent.run(max_steps=15)
    print(f"Result: {result}")
    
    # Test checkout flow
    checkout_agent = Agent(
        task=(
            "Go to mystore.com, add the first product to cart, "
            "go to checkout, and verify the cart total is displayed"
        ),
        llm=llm
    )
    
    checkout_result = await checkout_agent.run(max_steps=20)
    print(f"Checkout test: {checkout_result}")

asyncio.run(test_ecommerce())
Use case: Automated regression testing for e-commerce platforms
Test complex forms and multi-step flows:
from browser_use import Agent, ChatOpenAI
import asyncio
import os

llm = ChatOpenAI(
    model="morph-computer-use-v0",
    api_key="YOUR_API_KEY",
    base_url="https://api.morphllm.com/v1"
)

async def test_form_submission():
    agent = Agent(
        task=(
            "Go to example.com/contact, fill in the form with: "
            "name='John Doe', email='john@example.com', "
            "message='Test message', then submit and verify success message appears"
        ),
        llm=llm
    )
    
    result = await agent.run(max_steps=12)
    
    if "success" in result.lower():
        print("✅ Form submission successful")
    else:
        print("❌ Form submission failed")
        print(result)

asyncio.run(test_form_submission())
Use case: Continuous testing of lead generation forms
Test login flows and authenticated sessions:
from browser_use import Agent, ChatOpenAI
import asyncio
import os

llm = ChatOpenAI(
    model="morph-computer-use-v0",
    api_key="YOUR_API_KEY",
    base_url="https://api.morphllm.com/v1"
)

async def test_login_flow():
    agent = Agent(
        task=(
            "Go to myapp.com/login, enter email 'test@example.com' "
            "and password 'TestPass123', click login, and verify "
            "the dashboard page loads with the welcome message"
        ),
        llm=llm
    )
    
    result = await agent.run(max_steps=10)
    print(f"Login test result: {result}")

asyncio.run(test_login_flow())
Security note: Use test accounts only. Never use real credentials in automated tests.
Extract structured data from web pages:
from browser_use import Agent, ChatOpenAI
import asyncio
import json
import os

llm = ChatOpenAI(
    model="morph-computer-use-v0",
    api_key="YOUR_API_KEY",
    base_url="https://api.morphllm.com/v1"
)

async def extract_product_data():
    agent = Agent(
        task=(
            "Go to amazon.com/product/B08N5WRWNW, extract the product title, "
            "price, rating, and number of reviews. Return as JSON format."
        ),
        llm=llm
    )
    
    result = await agent.run(max_steps=8)
    
    # Parse the extracted data
    try:
        data = json.loads(result)
        print(f"Product: {data.get('title')}")
        print(f"Price: {data.get('price')}")
        print(f"Rating: {data.get('rating')}")
    except json.JSONDecodeError:
        print("Raw result:", result)

asyncio.run(extract_product_data())
Use case: Competitive pricing analysis, product monitoring

Configuration

Custom Browser Options

Control browser behavior with browser-use config:
from browser_use import Agent, Browser, BrowserConfig, ChatOpenAI
import os

llm = ChatOpenAI(
    model="morph-computer-use-v0",
    api_key="YOUR_API_KEY",
    base_url="https://api.morphllm.com/v1"
)

# Configure browser
browser = Browser(
    config=BrowserConfig(
        headless=True,              # Run in background
        disable_security=False,     # Keep security enabled
        extra_chromium_args=[
            '--window-size=1920,1080'
        ]
    )
)

agent = Agent(
    task="Navigate to example.com and take a screenshot",
    llm=llm,
    browser=browser
)

result = await agent.run()

Error Handling

Handle failures gracefully:
from browser_use import Agent, ChatOpenAI
import asyncio
import os

llm = ChatOpenAI(
    model="morph-computer-use-v0",
    api_key="YOUR_API_KEY",
    base_url="https://api.morphllm.com/v1"
)

async def test_with_retry():
    max_retries = 3
    
    for attempt in range(max_retries):
        try:
            agent = Agent(
                task="Test the checkout flow at myapp.com",
                llm=llm
            )
            
            result = await agent.run(max_steps=15)
            
            if "success" in result.lower():
                print(f"✅ Test passed on attempt {attempt + 1}")
                return result
            else:
                print(f"⚠️ Test inconclusive on attempt {attempt + 1}")
                
        except Exception as e:
            print(f"❌ Attempt {attempt + 1} failed: {e}")
            
            if attempt == max_retries - 1:
                raise
            
            # Wait before retry
            await asyncio.sleep(2)

asyncio.run(test_with_retry())

Advanced Usage

Parallel Testing

Run multiple tests concurrently:
from browser_use import Agent, ChatOpenAI
import asyncio
import os

llm = ChatOpenAI(
    model="morph-computer-use-v0",
    api_key="YOUR_API_KEY",
    base_url="https://api.morphllm.com/v1"
)

async def run_test(test_name: str, task: str):
    agent = Agent(task=task, llm=llm)
    result = await agent.run(max_steps=10)
    return {"test": test_name, "result": result}

async def parallel_tests():
    tests = [
        ("Homepage", "Go to myapp.com and verify the hero section loads"),
        ("Pricing", "Go to myapp.com/pricing and count the pricing tiers"),
        ("Contact", "Go to myapp.com/contact and verify the form is present")
    ]
    
    # Run all tests in parallel
    results = await asyncio.gather(*[
        run_test(name, task) for name, task in tests
    ])
    
    for result in results:
        print(f"{result['test']}: {result['result']}")

asyncio.run(parallel_tests())

Integration with Pytest

Create a test suite:
# test_browser_flows.py
import pytest
from browser_use import Agent, ChatOpenAI
import os

@pytest.fixture
def llm():
    return ChatOpenAI(
        model="morph-computer-use-v0",
        api_key="YOUR_API_KEY",
        base_url="https://api.morphllm.com/v1"
    )

@pytest.mark.asyncio
async def test_homepage_loads(llm):
    agent = Agent(
        task="Go to myapp.com and verify the page loads",
        llm=llm
    )
    result = await agent.run(max_steps=5)
    assert "loaded" in result.lower() or "success" in result.lower()

@pytest.mark.asyncio
async def test_search_functionality(llm):
    agent = Agent(
        task="Go to myapp.com, search for 'test', verify results appear",
        llm=llm
    )
    result = await agent.run(max_steps=10)
    assert "result" in result.lower()

# Run with: pytest test_browser_flows.py -v

Comparison: Morph SDK vs browser-use

Choose the right tool for your use case:
FeatureMorph SDK (TypeScript)browser-use + Morph
LanguageTypeScript/JavaScriptPython
Setupbun add @morphllm/morphsdkpip install browser-use
IntegrationBuilt for MorphOpenAI-compatible
Live Sessions✅ Built-in❌ Not available
Recording✅ Video + rrweb + logs❌ Not available
Async TaskscreateTask() with polling❌ Direct execution only
Best ForNode.js apps, dashboardsPython scripts, data pipelines
Use Morph SDK if: You’re building in TypeScript and want live sessions, recordings, or async task tracking Use browser-use if: You’re in Python and want the browser-use agent interface

Troubleshooting

Error: 401 Unauthorized or Invalid API keyFix:
  1. Get your API key at app.morphllm.com/settings/api-keys
  2. Set environment variable: export MORPH_API_KEY=sk-your-key
  3. Verify it’s loaded: print(os.environ.get('MORPH_API_KEY'))
import os

# Verify API key is set
if not os.environ.get('MORPH_API_KEY'):
    raise ValueError("MORPH_API_KEY not set in environment")
Error: Browser crashes, hangs, or times outFix: Adjust browser config and max_steps
from browser_use import Agent, Browser, BrowserConfig

browser = Browser(
    config=BrowserConfig(
        headless=True,
        disable_security=False,
        extra_chromium_args=[
            '--no-sandbox',            # For containers
            '--disable-dev-shm-usage', # Prevent memory issues
            '--disable-gpu'            # Stability
        ]
    )
)

agent = Agent(
    task="Your task here",
    llm=llm,
    browser=browser
)

# Increase max_steps for complex tasks
result = await agent.run(max_steps=25)
Error: Agent gives up or can’t complete the taskFix: Make task more specific and increase steps
# ❌ Too vague
task = "Test the app"

# ✅ Specific and actionable
task = (
    "Go to myapp.com, click the 'Sign Up' button, "
    "verify the registration form appears with email and password fields"
)

# Use enough steps for the complexity
agent = Agent(task=task, llm=llm)
result = await agent.run(max_steps=15)  # Adjust based on task
Error: playwright._impl._errors.Error: Executable doesn't existFix: Install Playwright browsers
# Install all browsers
playwright install

# Or install specific browser
playwright install chromium

# For CI/CD, install system dependencies
playwright install-deps

Next Steps