Skip to content

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

commit

Matic Zavadlal63cb5613a5a3
diff --git a/browser_use/llm/anthropic/chat.py b/browser_use/llm/anthropic/chat.py
index 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 | ModelParam
max_tokens: int = 8192
temperature: float | None = None
+ top_p: float | None = None
+ seed: int | None = None
# Client initialization parameters
api_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_params
def get_client(self) -> AsyncAnthropic:
diff --git a/browser_use/llm/aws/chat_anthropic.py b/browser_use/llm/aws/chat_anthropic.py
index 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 = None
top_k: int | None = None
stop_sequences: list[str] | None = None
+ seed: int | None = None
# AWS credentials and configuration
aws_access_key: str | None = None
@@ -109,6 +110,8 @@ class ChatAnthropicBedrock(ChatAWSBedrock):
client_params['top_p'] = self.top_p
if self.top_k is not None:
client_params['top_k'] = self.top_k
+ if self.seed is not None:
+ client_params['seed'] = self.seed
if self.stop_sequences is not None:
client_params['stop_sequences'] = self.stop_sequences
diff --git a/browser_use/llm/aws/chat_bedrock.py b/browser_use/llm/aws/chat_bedrock.py
index 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 = 4096
temperature: float | None = None
top_p: float | None = None
+ seed: int | None = None
stop_sequences: list[str] | None = None
# AWS credentials and configuration
@@ -105,6 +106,8 @@ class ChatAWSBedrock(BaseChatModel):
config['topP'] = self.top_p
if self.stop_sequences is not None:
config['stopSequences'] = self.stop_sequences
+ if self.seed is not None:
+ config['seed'] = self.seed
return config
def _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.py
index 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 = None
temperature: 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.temperature
if 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.py
index 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 configuration
model: VerifiedGeminiModels | str
temperature: float | None = None
+ top_p: float | None = None
+ seed: int | None = None
thinking_budget: int | None = None
config: 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_dict
diff --git a/browser_use/llm/groq/chat.py b/browser_use/llm/groq/chat.py
index 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 params
temperature: float | None = None
service_tier: Literal['auto', 'on_demand', 'flex'] | None = None
+ top_p: float | None = None
+ seed: int | None = None
# Client initialization parameters
api_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.py
index 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 parameters
diff --git a/browser_use/llm/openai/chat.py b/browser_use/llm/openai/chat.py
index 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.2
frequency_penalty: float | None = 0.05
reasoning_effort: ReasoningEffort = 'low'
+ seed: int | None = None
+ top_p: float | None = None
# Client initialization parameters
api_key: str | None = None
@@ -52,7 +54,6 @@ class ChatOpenAI(BaseChatModel):
http_client: httpx.AsyncClient | None = None
_strict_response_validation: bool = False
max_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_effort
model_params['temperature'] = 1
diff --git a/browser_use/llm/openrouter/chat.py b/browser_use/llm/openrouter/chat.py
index 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 params
temperature: float | None = None
+ top_p: float | None = None
+ seed: int | None = None
# Client initialization parameters
api_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.mdx
index 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.mdx
new file mode 100644
index 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.mdx
index 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.mdx
index 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 yarn
yarn global add mintlify
diff --git a/docs/docs.json b/docs/docs.json
index 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"
]
},
{