Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
commit
Matic Zavadlal63cb5613a5a3
diff --git a/browser_use/llm/anthropic/chat.py b/browser_use/llm/anthropic/chat.pyindex e3a45cb89..d0f60f84b 100644--- a/browser_use/llm/anthropic/chat.py+++ b/browser_use/llm/anthropic/chat.py@@ -39,6 +39,8 @@ class ChatAnthropic(BaseChatModel):model: str | ModelParammax_tokens: int = 8192temperature: float | None = None+ top_p: float | None = None+ seed: int | None = None# Client initialization parametersapi_key: str | None = None@@ -65,6 +67,8 @@ class ChatAnthropic(BaseChatModel):'max_retries': self.max_retries,'default_headers': self.default_headers,'default_query': self.default_query,+ 'top_p': self.top_p,+ 'seed': self.seed,}# Create client_params dict with non-None values and non-NotGiven values@@ -86,6 +90,12 @@ class ChatAnthropic(BaseChatModel):if self.max_tokens is not None:client_params['max_tokens'] = self.max_tokens+ if self.top_p is not None:+ client_params['top_p'] = self.top_p++ if self.seed is not None:+ client_params['seed'] = self.seed+return client_paramsdef get_client(self) -> AsyncAnthropic:diff --git a/browser_use/llm/aws/chat_anthropic.py b/browser_use/llm/aws/chat_anthropic.pyindex 5d94fdc75..65eba410c 100644--- a/browser_use/llm/aws/chat_anthropic.py+++ b/browser_use/llm/aws/chat_anthropic.py@@ -45,6 +45,7 @@ class ChatAnthropicBedrock(ChatAWSBedrock):top_p: float | None = Nonetop_k: int | None = Nonestop_sequences: list[str] | None = None+ seed: int | None = None# AWS credentials and configurationaws_access_key: str | None = None@@ -109,6 +110,8 @@ class ChatAnthropicBedrock(ChatAWSBedrock):client_params['top_p'] = self.top_pif self.top_k is not None:client_params['top_k'] = self.top_k+ if self.seed is not None:+ client_params['seed'] = self.seedif self.stop_sequences is not None:client_params['stop_sequences'] = self.stop_sequencesdiff --git a/browser_use/llm/aws/chat_bedrock.py b/browser_use/llm/aws/chat_bedrock.pyindex 3a1259544..bafbb8fb0 100644--- a/browser_use/llm/aws/chat_bedrock.py+++ b/browser_use/llm/aws/chat_bedrock.py@@ -40,6 +40,7 @@ class ChatAWSBedrock(BaseChatModel):max_tokens: int | None = 4096temperature: float | None = Nonetop_p: float | None = None+ seed: int | None = Nonestop_sequences: list[str] | None = None# AWS credentials and configuration@@ -105,6 +106,8 @@ class ChatAWSBedrock(BaseChatModel):config['topP'] = self.top_pif self.stop_sequences is not None:config['stopSequences'] = self.stop_sequences+ if self.seed is not None:+ config['seed'] = self.seedreturn configdef _format_tools_for_request(self, output_format: type[BaseModel]) -> list[dict[str, Any]]:diff --git a/browser_use/llm/deepseek/chat.py b/browser_use/llm/deepseek/chat.pyindex 49b6f48d2..479d16439 100644--- a/browser_use/llm/deepseek/chat.py+++ b/browser_use/llm/deepseek/chat.py@@ -34,6 +34,8 @@ class ChatDeepSeek(BaseChatModel):# 生成参数max_tokens: int | None = Nonetemperature: float | None = None+ top_p: float | None = None+ seed: int | None = None# 连接参数api_key: str | None = None@@ -92,10 +94,15 @@ class ChatDeepSeek(BaseChatModel):client = self._client()ds_messages = DeepSeekMessageSerializer.serialize_messages(messages)common: dict[str, Any] = {}+if self.temperature is not None:common['temperature'] = self.temperatureif self.max_tokens is not None:common['max_tokens'] = self.max_tokens+ if self.top_p is not None:+ common['top_p'] = self.top_p+ if self.seed is not None:+ common['seed'] = self.seed# Beta 对话前缀续写(见官方文档)if self.base_url and str(self.base_url).endswith('/beta'):diff --git a/browser_use/llm/google/chat.py b/browser_use/llm/google/chat.pyindex 7a2a7329b..95423f584 100644--- a/browser_use/llm/google/chat.py+++ b/browser_use/llm/google/chat.py@@ -74,6 +74,8 @@ class ChatGoogle(BaseChatModel):# Model configurationmodel: VerifiedGeminiModels | strtemperature: float | None = None+ top_p: float | None = None+ seed: int | None = Nonethinking_budget: int | None = Noneconfig: types.GenerateContentConfigDict | None = None@@ -181,6 +183,12 @@ class ChatGoogle(BaseChatModel):if system_instruction:config['system_instruction'] = system_instruction+ if self.top_p is not None:+ config['top_p'] = self.top_p++ if self.seed is not None:+ config['seed'] = self.seed+if self.thinking_budget is not None:thinking_config_dict: types.ThinkingConfigDict = {'thinking_budget': self.thinking_budget}config['thinking_config'] = thinking_config_dictdiff --git a/browser_use/llm/groq/chat.py b/browser_use/llm/groq/chat.pyindex 8a85eff40..f67b94ac4 100644--- a/browser_use/llm/groq/chat.py+++ b/browser_use/llm/groq/chat.py@@ -60,6 +60,8 @@ class ChatGroq(BaseChatModel):# Model paramstemperature: float | None = Noneservice_tier: Literal['auto', 'on_demand', 'flex'] | None = None+ top_p: float | None = None+ seed: int | None = None# Client initialization parametersapi_key: str | None = None@@ -145,8 +147,10 @@ class ChatGroq(BaseChatModel):chat_completion = await self.get_client().chat.completions.create(messages=groq_messages,model=self.model,- temperature=self.temperature,service_tier=self.service_tier,+ temperature=self.temperature,+ top_p=self.top_p,+ seed=self.seed,)usage = self._get_usage(chat_completion)return ChatInvokeCompletion(@@ -194,6 +198,8 @@ class ChatGroq(BaseChatModel):model=self.model,messages=groq_messages,temperature=self.temperature,+ top_p=self.top_p,+ seed=self.seed,tools=[tool],tool_choice=tool_choice,service_tier=self.service_tier,@@ -205,6 +211,8 @@ class ChatGroq(BaseChatModel):model=self.model,messages=groq_messages,temperature=self.temperature,+ top_p=self.top_p,+ seed=self.seed,response_format=ResponseFormatResponseFormatJsonSchema(json_schema=ResponseFormatResponseFormatJsonSchemaJsonSchema(name=output_format.__name__,diff --git a/browser_use/llm/ollama/chat.py b/browser_use/llm/ollama/chat.pyindex 88654e347..cf6d86eef 100644--- a/browser_use/llm/ollama/chat.py+++ b/browser_use/llm/ollama/chat.py@@ -23,6 +23,7 @@ class ChatOllama(BaseChatModel):model: str# # Model params+ # TODO (matic): Why is this commented out?# temperature: float | None = None# Client initialization parametersdiff --git a/browser_use/llm/openai/chat.py b/browser_use/llm/openai/chat.pyindex 4883478b1..bf0a456d1 100644--- a/browser_use/llm/openai/chat.py+++ b/browser_use/llm/openai/chat.py@@ -38,6 +38,8 @@ class ChatOpenAI(BaseChatModel):temperature: float | None = 0.2frequency_penalty: float | None = 0.05reasoning_effort: ReasoningEffort = 'low'+ seed: int | None = None+ top_p: float | None = None# Client initialization parametersapi_key: str | None = None@@ -52,7 +54,6 @@ class ChatOpenAI(BaseChatModel):http_client: httpx.AsyncClient | None = None_strict_response_validation: bool = Falsemax_completion_tokens: int | None = 8000- top_p: float | None = None# Static@property@@ -160,6 +161,9 @@ class ChatOpenAI(BaseChatModel):if self.top_p is not None:model_params['top_p'] = self.top_p+ if self.seed is not None:+ model_params['seed'] = self.seed+if self.model in ReasoningModels:model_params['reasoning_effort'] = self.reasoning_effortmodel_params['temperature'] = 1diff --git a/browser_use/llm/openrouter/chat.py b/browser_use/llm/openrouter/chat.pyindex a85fbb245..a59401bd1 100644--- a/browser_use/llm/openrouter/chat.py+++ b/browser_use/llm/openrouter/chat.py@@ -35,6 +35,8 @@ class ChatOpenRouter(BaseChatModel):# Model paramstemperature: float | None = None+ top_p: float | None = None+ seed: int | None = None# Client initialization parametersapi_key: str | None = None@@ -63,6 +65,8 @@ class ChatOpenRouter(BaseChatModel):'default_headers': self.default_headers,'default_query': self.default_query,'_strict_response_validation': self._strict_response_validation,+ 'top_p': self.top_p,+ 'seed': self.seed,}# Create client_params dict with non-None values@@ -141,6 +145,8 @@ class ChatOpenRouter(BaseChatModel):model=self.model,messages=openrouter_messages,temperature=self.temperature,+ top_p=self.top_p,+ seed=self.seed,extra_headers=extra_headers,)@@ -165,6 +171,8 @@ class ChatOpenRouter(BaseChatModel):model=self.model,messages=openrouter_messages,temperature=self.temperature,+ top_p=self.top_p,+ seed=self.seed,response_format=ResponseFormatJSONSchema(json_schema=response_format_schema,type='json_schema',diff --git a/docs/cloud/implementation.mdx b/docs/cloud/implementation.mdxindex c7b400e33..9f78f94f1 100644--- a/docs/cloud/implementation.mdx+++ b/docs/cloud/implementation.mdx@@ -1,7 +1,7 @@----title: "Implementing the API"-description: "Learn how to implement the Browser Use API in Python"-icon: "code"+title: "Using the API"+description: "Learn how to use the Browser Use API in Python"+icon: "book"---This guide shows how to implement common API patterns using Python. We'll create a complete example that creates and monitors a browser automation task.diff --git a/docs/cloud/openapi.mdx b/docs/cloud/openapi.mdxnew file mode 100644index 000000000..66feb4cd2--- /dev/null+++ b/docs/cloud/openapi.mdx@@ -0,0 +1,83 @@+---+title: "OpenAPI Client"+description: "Learn how to generate a type safe client for the Browser Use API"+icon: "book"+---++## Generating a Type Safe TypeScript Client++Use [OpenAPI TS](https://openapi-ts.dev/) library to generate a type safe TypeScript client for the Browser Use API.++The following guide shows how to create a simple type-safe `fetch` client, but you can also use other generators.++- React Query - https://openapi-ts.dev/openapi-react-query/+- SWR - https://openapi-ts.dev/swr-openapi/+++<CodeGroup>+```bash npm+npm install openapi-fetch+npm install -D openapi-typescript typescript+```++```bash yarn+yarn add openapi-fetch+yarn add -D openapi-typescript typescript+```+```bash pnpm+pnpm add openapi-fetch+pnpm add -D openapi-typescript typescript+```+</CodeGroup>++```json title="package.json"+{+ "scripts": {+ "openapi:gen": "openapi-typescript https://api.browser-use.com/openapi.json -o ./src/lib/api/v1.d.ts"+ }+}+```++```bash+pnpm openapi:gen+```++```ts+// client.ts++'use client'++import createClient from 'openapi-fetch'+import { paths } from '@/lib/api/v1'++export type Client = ReturnType<typeof createClient<paths>>++export const client = createClient<paths>({+ baseUrl: 'https://api.browser-use.com/',++ // NOTE: You can get your API key from https://cloud.browser-use.com/billing!+ headers: { Authorization: `Bearer ${apiKey}` },+})++```++## Generating a Type Safe Python Client++Use [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) to generate a modern Python client:++```bash+# Install the generator+pipx install openapi-python-client --include-deps++# Generate the client+openapi-python-client generate --url http://api.browser-use.com/openapi.json+```++This will create a Python package with full type hints, modern dataclasses, and async support.++++<Note>+ Need help? Contact our support team at [email protected] or join our+ [Discord community](https://link.browser-use.com/discord)+</Note>diff --git a/docs/cloud/quickstart.mdx b/docs/cloud/quickstart.mdxindex ccd9e455c..4e0148311 100644--- a/docs/cloud/quickstart.mdx+++ b/docs/cloud/quickstart.mdx@@ -87,43 +87,6 @@ Control running tasks with these operations:For detailed API documentation, see the tabs on the left, which include the full coverage of the API.-## Building your own client (OpenAPI)--<Note>- We recommend this only if you don't need control and only need to run simple- tasks.-</Note>--The best way to build your own client is to use our [OpenAPI specification](http://api.browser-use.com/openapi.json) to generate a type-safe client library.--### Python--Use [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) to generate a modern Python client:--```bash-# Install the generator-pipx install openapi-python-client --include-deps--# Generate the client-openapi-python-client generate --url http://api.browser-use.com/openapi.json-```--This will create a Python package with full type hints, modern dataclasses, and async support.--### TypeScript/JavaScript--For TypeScript projects, use [openapi-typescript](https://www.npmjs.com/package/openapi-typescript) to generate type definitions:--```bash-# Install the generator-npm install -D openapi-typescript--# Generate the types-npx openapi-typescript http://api.browser-use.com/openapi.json -o browser-use-api.ts-```--This will create TypeScript definitions you can use with your preferred HTTP client.-<Note>Need help? Contact our support team at [email protected] or join our[Discord community](https://link.browser-use.com/discord)diff --git a/docs/development.mdx b/docs/development.mdxindex bd0ed7d10..61b85ee42 100644--- a/docs/development.mdx+++ b/docs/development.mdx@@ -13,9 +13,9 @@ Follow these steps to install and run Mintlify on your operating system:<CodeGroup>- ```bash npm- npm i -g mintlify- ```+```bash npm+npm i -g mintlify+``````bash yarnyarn global add mintlifydiff --git a/docs/docs.json b/docs/docs.jsonindex d2112349f..3d58ff679 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -58,9 +58,10 @@"group": "Cloud API","pages": ["cloud/quickstart",+ "cloud/authentication",+ "cloud/openapi","cloud/implementation",- "cloud/webhooks",- "cloud/authentication"+ "cloud/webhooks"]},{