Files
browser-use/examples/cloud/README.md
Magnus Müller de0488031d Squashed commit of the following:
commit 92d1732a40
Merge: fa4ff47a efcd2b33
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:18:35 2025 -0700

    Merge main

commit fa4ff47ae4
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:03:04 2025 -0700

    Laminar info mode

commit 8625aa9ba9
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:02:54 2025 -0700

    Default to flash for browser use llm

commit 69a517ad7c
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:02:44 2025 -0700

    Update example

commit c91467c51d
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 08:02:15 2025 -0700

    Update example

commit 4e2b3f1306
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 07:54:05 2025 -0700

    Linter

commit e8d6936a47
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 07:53:43 2025 -0700

    Example

commit 961d6fc451
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 07:52:23 2025 -0700

    Update default links

commit 0b2853859b
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Wed Oct 8 07:44:59 2025 -0700

    Default fast fasle

commit 9d67594b63
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 22:01:24 2025 -0700

    Simplify

commit f5712bdec0
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 21:45:00 2025 -0700

    Parsing json

commit 503af624dd
Merge: ef7fa1e4 0d2522b1
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 21:04:31 2025 -0700

    Merge branch 'flat-output' of https://github.com/browser-use/browser-use into flat-output

commit ef7fa1e401
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 21:04:28 2025 -0700

    Add prompt description handling for browser-use cloud service

    - Enhanced the Agent class to generate and pass prompt descriptions to the LLM when using the browser-use provider.
    - Updated the ChatBrowserUse class to accept an optional prompt_description parameter in the ainvoke method.
    - Modified the tracked_ainvoke function in TokenCost to forward additional keyword arguments.
    - Adjusted example model to initialize Laminar for tracing.

commit 0d2522b1f9
Author: Gregor Žunič <36313686+gregpr07@users.noreply.github.com>
Date:   Tue Oct 7 20:23:39 2025 -0700

    updated default base url

commit 0a2e6d6520
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 18:50:56 2025 -0700

    Hide api key

commit 96bba9692b
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 18:49:05 2025 -0700

    Add env var loading and validation to ChatBrowserUse, update example

commit c2e57a3bab
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 18:36:31 2025 -0700

    Linter

commit 3d4cc1dbec
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:28:10 2025 -0700

    Rename

commit 14ab0b75fe
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:21:52 2025 -0700

    Rename super_fast to fast parameter in ChatBrowserUse

commit 7fab3c47d3
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:08:10 2025 -0700

    Update system prompt

commit 2066e77b98
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:07:51 2025 -0700

    Del claude file

commit 297b767e91
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 16:01:50 2025 -0700

    Revert flash system prompt to JSON format

    - Reverted system_prompt_flash.md to main (JSON format)
    - Added examples/models/browser_use_cloud.py for llm-use cloud service
    - llm-use service will inject unstructured format on the server side

commit 99af55f8e9
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 15:58:40 2025 -0700

    Example

commit 657ff0d352
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 15:54:23 2025 -0700

    Remove unused

commit a42123d8e5
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 15:49:54 2025 -0700

    ignore

commit de4fe19020
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 15:48:01 2025 -0700

    Example

commit 27e5ab9947
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 14:29:01 2025 -0700

    Add llm-use cloud client example

    - ChatLLMUseCloud: Browser-use compatible client for llm-use service
    - Implements BaseChatModel protocol with proper typing
    - Includes credit checking before/after tasks
    - Error handling for 401/402/500 responses
    - Converts messages between browser-use and HTTP API formats
    - Returns ChatInvokeCompletion with usage stats

    Usage:
      export LLM_USE_URL='https://your-app.railway.app'
      export LLM_USE_API_KEY='your-key'
      python examples/llm_use_cloud_client.py

commit a47a448005
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Tue Oct 7 13:03:59 2025 -0700

    Enhance response parsing in ChatBrowserUse to handle structured data from the API, including debug logging for received data keys.

commit e79c7dc633
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Mon Oct 6 19:39:29 2025 -0700

    Include browser-use llm

commit 584d977154
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Mon Oct 6 17:55:31 2025 -0700

    Linter

commit b0ac87076a
Merge: 1183b8fe 0076775f
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Mon Oct 6 15:01:37 2025 -0700

    merge main

commit 1183b8fe6b
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 16:26:34 2025 -0700

    Fix done output action model

commit 852449b1bc
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 16:23:31 2025 -0700

    More debug info

commit a57ba25d36
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 16:07:15 2025 -0700

    Multiline parser

commit 2153dbe6aa
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 15:50:14 2025 -0700

    Fix custom output

commit ec5c08ba0f
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 15:36:54 2025 -0700

    Fix files in output

commit 7444048e8f
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 15:28:09 2025 -0700

    Update codebase with unstructured output

commit a8f05b4611
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 14:55:20 2025 -0700

    Save systemprompt

commit d7d112c569
Author: Magnus Müller <67061560+MagMueller@users.noreply.github.com>
Date:   Sun Oct 5 14:51:24 2025 -0700

    new parser
2025-10-08 08:39:24 -07:00

138 lines
4.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Browser Use Cloud Examples 🚀
Welcome to the Browser Use Cloud examples! This folder contains progressively complex examples to help you get started with the Browser Use Cloud API quickly and efficiently.
## 📋 Prerequisites
1. **API Key**: Get your API key from [cloud.browser-use.com/dashboard/api](https://cloud.browser-use.com/dashboard/api)
2. **Python Environment**: Python 3.11+ with dependencies
3. **Environment Variables**: Configure your API settings
### Quick Setup
```bash
# Create virtual environment and install dependencies (from project root)
uv venv --python 3.11
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv sync
# Set environment variables
export BROWSER_USE_API_KEY="your_api_key_here"
export BROWSER_USE_BASE_URL="https://api.browser-use.com/api/v1" # Optional
export BROWSER_USE_TIMEOUT="30" # Optional: request timeout in seconds
# Or use .env file (recommended)
cp examples/cloud/env.example .env
# Edit .env with your values
# Run examples from project root
python examples/cloud/01_basic_task.py
```
## 🎯 Examples Overview
### 🚀 Easy Cloud Setup Examples
- **[01_basic_task.py](./01_basic_task.py)** - Your first cloud task (start here!)
- **[02_fast_mode_gemini.py](./02_fast_mode_gemini.py)** - ⚡ Ultra-fast mode with Gemini Flash & Fireship humor
- **[03_structured_output.py](./03_structured_output.py)** - Get structured JSON responses
- **[04_proxy_usage.py](./04_proxy_usage.py)** - 🌍 Proxy for geo-restrictions & captcha solving
- **[05_search_api.py](./05_search_api.py)** - 🔍 Search API for content extraction (BETA)
## 💰 Cost Optimization Tips
1. **Use Gemini Flash** for fastest/cheapest execution ($0.01/step)
2. **Disable proxy** when not needed for captcha solving
3. **Disable element highlighting** for better performance
4. **Set max_agent_steps** to prevent runaway costs
5. **Use structured output** to reduce parsing overhead
6. **Add timeouts and retries** for reliability in production
7. **Use domain restrictions** when working with secrets
## 🎨 Fast Mode Configuration
For maximum speed and cost efficiency:
```python
{
"llm_model": "gemini-2.5-flash",
"use_proxy": False,
"highlight_elements": False,
"use_adblock": True,
"max_agent_steps": 50
}
```
## 🔐 Security & Advanced Features
### Using Proxy
```python
{
"use_proxy": True,
"proxy_country_code": "us", # 'us', 'fr', 'it', 'jp', 'au', 'de', 'fi', 'ca'
}
```
### Passing Secrets Securely
```python
{
"secrets": {
"username": "your_username",
"password": "your_password",
"api_key": "your_api_key"
},
"allowed_domains": ["*.yoursite.com"] # Recommended with secrets
}
```
## 🔍 Search API (BETA)
The Search API extracts content by actually browsing websites (not cached results):
### Simple Search (Multi-site)
```python
# Cost: 1¢ × depth × websites
{
"query": "latest AI news",
"max_websites": 5,
"depth": 2
}
```
### URL Search (Single site)
```python
# Cost: 1¢ × depth
{
"url": "https://example.com",
"query": "pricing information",
"depth": 3
}
```
## 🔗 Quick Links
- [Cloud API Documentation](https://docs.browser-use.com/cloud)
- [API Reference](https://docs.browser-use.com/api-reference)
- [Pricing](https://cloud.browser-use.com/billing)
- [Discord Community](https://link.browser-use.com/discord)
## 🔧 Production Best Practices
- **Timeouts**: All examples include 30-second timeouts with retry logic
- **Error Handling**: Comprehensive error catching and status code validation
- **Security**: Use environment variables, domain restrictions with secrets
- **Reliability**: Built-in retries for network issues and rate limits
- **Automation**: CLI arguments instead of interactive prompts for CI/CD
## 🆘 Support
Need help?
- 📧 Email: support@browser-use.com
- 💬 Discord: [Join our community](https://link.browser-use.com/discord)
- 📖 Docs: <https://docs.browser-use.com>
---
**💡 Pro Tip**: Start with `01_basic_task.py` and work your way up. Each example builds on the previous ones!