Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

extra headers

Gregor Žunič3d12b6d5b28c
diff --git a/browser_use/browser/cloud/cloud.py b/browser_use/browser/cloud/cloud.py
index b6e6bfd74..58b3c4ac9 100644
--- a/browser_use/browser/cloud/cloud.py
+++ b/browser_use/browser/cloud/cloud.py
@@ -99,7 +99,9 @@ class CloudBrowserClient:
raise
raise CloudBrowserError(f'Unexpected error creating cloud browser: {e}')
- async def stop_browser(self, session_id: str | None = None) -> CloudBrowserResponse:
+ async def stop_browser(
+ self, session_id: str | None = None, extra_headers: dict[str, str] | None = None
+ ) -> CloudBrowserResponse:
"""Stop a cloud browser session.
Args:
@@ -136,7 +138,7 @@ class CloudBrowserClient:
'No authentication token found. Please set BROWSER_USE_API_KEY environment variable to authenticate with the cloud service. You can also create an API key at https://cloud.browser-use.com/new-api-key'
)
- headers = {'X-Browser-Use-API-Key': api_token, 'Content-Type': 'application/json'}
+ headers = {'X-Browser-Use-API-Key': api_token, 'Content-Type': 'application/json', **(extra_headers or {})}
request_body = {'action': 'stop'}