Cloud browser automation with @sandbox decorator for persistent auth and proxy routing

Execute browser automation tasks in the cloud with the @sandbox decorator - a convenience wrapper that automatically configures Browser Use for cloud-based execution with advanced features like persistent authentication and proxy routing.
The @sandbox decorator is a simple wrapper that automatically configures your browser automation to run in the cloud with custom settings, eliminating the need for manual browser setup and configuration.
uvx browser-use init --template sandbox
Optional for persistent authentication:
The @sandbox decorator automatically injects a cloud-configured browser into your function:
from browser_use import sandbox
@sandbox(
cloud_profile_id=os.getenv('CLOUD_PROFILE_ID'),
cloud_proxy_country_code='us',
cloud_timeout=60
)
async def main(browser: Browser):
agent = Agent(task="Your task here", browser=browser)
await agent.run()The browser parameter is automatically configured with:
use_cloud=True)All settings are controlled via environment variables in your .env file:
# Required
BROWSER_USE_API_KEY=your-key-here
# Optional - Cloud Settings
CLOUD_PROFILE_ID=your-profile-id-here # For persistent authentication
CLOUD_PROXY_COUNTRY_CODE=us # Two-letter ISO country code
CLOUD_TIMEOUT=60 # Session timeout in minutesPersistent Authentication
Country-Specific Automation
Zero Local Setup
Use any two-letter ISO country code: us, uk, de, jp, au, fr, ca, etc.
See ISO 3166-1 alpha-2 for the complete list.
π See the detailed README for cloud profiles setup, troubleshooting, and advanced configuration.