Skip to content

Commit 4ec0160

Browse files
authored
Merge pull request #6 from browser-use/release-please--branches--main--changes--next
release: 1.0.0
2 parents 47045d2 + 391812b commit 4ec0160

File tree

15 files changed

+112
-60
lines changed

15 files changed

+112
-60
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.3.0"
2+
".": "1.0.0"
33
}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.0.0 (2025-08-20)
4+
5+
Full Changelog: [v0.3.0...v1.0.0](https://github.com/browser-use/browser-use-python/compare/v0.3.0...v1.0.0)
6+
37
## 0.3.0 (2025-08-20)
48

59
Full Changelog: [v0.2.0...v0.3.0](https://github.com/browser-use/browser-use-python/compare/v0.2.0...v0.3.0)

README.md

Lines changed: 71 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,28 @@
1-
# Browser Use Python API library
1+
<img src="./assets/cloud-banner-python.png" alt="Browser Use Python" width="full"/>
22

3-
<!-- prettier-ignore -->
4-
[![PyPI version](https://img.shields.io/pypi/v/browser-use-sdk.svg?label=pypi%20(stable))](https://pypi.org/project/browser-use-sdk/)
5-
6-
The Browser Use Python library provides convenient access to the Browser Use REST API from any Python 3.8+
7-
application. The library includes type definitions for all request params and response fields,
8-
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
9-
10-
It is generated with [Stainless](https://www.stainless.com/).
11-
12-
## Documentation
13-
14-
The REST API documentation can be found on [docs.browser-use.com](https://docs.browser-use.com/cloud/). The full API of this library can be found in [api.md](api.md).
15-
16-
## Installation
3+
[![PyPI version](<https://img.shields.io/pypi/v/browser-use-sdk.svg?label=pypi%20(stable)>)](https://pypi.org/project/browser-use-sdk/)
174

185
```sh
19-
# install from PyPI
206
pip install browser-use-sdk
217
```
228

23-
## Usage
9+
## Quick Start
2410

25-
The full API of this library can be found in [api.md](api.md).
11+
> Get your API Key at [Browser Use Cloud](https://cloud.browser-use.com)!
2612
2713
```python
28-
import os
2914
from browser_use_sdk import BrowserUse
3015

31-
client = BrowserUse(
32-
api_key=os.environ.get("BROWSER_USE_API_KEY"), # This is the default and can be omitted
33-
)
16+
client = BrowserUse()
3417

35-
task = client.tasks.create(
36-
task="Search for the top 10 Hacker News posts and return the title and url.",
18+
run = client.tasks.run(
19+
task="Search for the top 10 Hacker News posts and return the title and url."
3720
)
38-
print(task.id)
21+
22+
run.done_output
3923
```
4024

41-
While you can provide an `api_key` keyword argument,
42-
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
43-
to add `BROWSER_USE_API_KEY="My API Key"` to your `.env` file
44-
so that your API Key is not stored in source control.
25+
> The full API of this library can be found in [api.md](api.md).
4526
4627
## Async usage
4728

@@ -58,10 +39,10 @@ client = AsyncBrowserUse(
5839

5940

6041
async def main() -> None:
61-
task = await client.tasks.create(
42+
task = await client.tasks.run(
6243
task="Search for the top 10 Hacker News posts and return the title and url.",
6344
)
64-
print(task.id)
45+
print(task.done_output)
6546

6647

6748
asyncio.run(main())
@@ -93,38 +74,80 @@ async def main() -> None:
9374
api_key="My API Key",
9475
http_client=DefaultAioHttpClient(),
9576
) as client:
96-
task = await client.tasks.create(
77+
task = await client.tasks.run(
9778
task="Search for the top 10 Hacker News posts and return the title and url.",
9879
)
99-
print(task.id)
80+
print(task.done_output)
81+
82+
83+
asyncio.run(main())
84+
```
85+
86+
## Structured Output with Pydantic
87+
88+
Browser Use Python SDK provides first class support for Pydantic models.
89+
90+
```py
91+
class HackerNewsPost(BaseModel):
92+
title: str
93+
url: str
94+
95+
class SearchResult(BaseModel):
96+
posts: List[HackerNewsPost]
97+
98+
async def main() -> None:
99+
result = await client.tasks.run(
100+
task="""
101+
Find top 10 Hacker News articles and return the title and url.
102+
""",
103+
structured_output_json=SearchResult,
104+
)
100105

106+
if structured_result.parsed_output is not None:
107+
print("Top HackerNews Posts:")
108+
for post in structured_result.parsed_output.posts:
109+
print(f" - {post.title} - {post.url}")
101110

102111
asyncio.run(main())
103112
```
104113

105-
## Using types
114+
## Streaming Updates with Async Iterators
106115

107-
Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
116+
```py
117+
class HackerNewsPost(BaseModel):
118+
title: str
119+
url: str
108120

109-
- Serializing back into JSON, `model.to_json()`
110-
- Converting to a dictionary, `model.to_dict()`
121+
class SearchResult(BaseModel):
122+
posts: List[HackerNewsPost]
111123

112-
Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.
113124

114-
## Nested params
125+
async def main() -> None:
126+
task = await client.tasks.create(
127+
task="""
128+
Find top 10 Hacker News articles and return the title and url.
129+
""",
130+
structured_output_json=SearchResult,
131+
)
115132

116-
Nested parameters are dictionaries, typed using `TypedDict`, for example:
133+
async for update in client.tasks.stream(structured_task.id, structured_output_json=SearchResult):
134+
if len(update.steps) > 0:
135+
last_step = update.steps[-1]
136+
print(f"{update.status}: {last_step.url} ({last_step.next_goal})")
137+
else:
138+
print(f"{update.status}")
117139

118-
```python
119-
from browser_use_sdk import BrowserUse
140+
if update.status == "finished":
141+
if update.parsed_output is None:
142+
print("No output...")
143+
else:
144+
print("Top HackerNews Posts:")
145+
for post in update.parsed_output.posts:
146+
print(f" - {post.title} - {post.url}")
120147

121-
client = BrowserUse()
148+
break
122149

123-
task = client.tasks.create(
124-
task="x",
125-
agent_settings={},
126-
)
127-
print(task.agent_settings)
150+
asyncio.run(main())
128151
```
129152

130153
## Handling errors

assets/cloud-banner-python.png

33.9 KB
Loading

examples/async_create.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ async def create_regular_task() -> None:
1616
res = await client.tasks.create(
1717
task="""
1818
Find top 10 Hacker News articles and return the title and url.
19-
"""
19+
""",
20+
agent_settings={"llm": "gemini-2.5-flash"},
2021
)
2122

2223
print(f"Regular Task ID: {res.id}")
@@ -35,6 +36,7 @@ class SearchResult(BaseModel):
3536
task="""
3637
Find top 10 Hacker News articles and return the title and url.
3738
""",
39+
agent_settings={"llm": "gpt-4.1"},
3840
structured_output_json=SearchResult,
3941
)
4042

examples/async_retrieve.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ async def retrieve_regular_task() -> None:
2222
regular_task = await client.tasks.create(
2323
task="""
2424
Find top 10 Hacker News articles and return the title and url.
25-
"""
25+
""",
26+
agent_settings={"llm": "gemini-2.5-flash"},
2627
)
2728

2829
print(f"Regular Task ID: {regular_task.id}")
@@ -58,6 +59,7 @@ class SearchResult(BaseModel):
5859
task="""
5960
Find top 10 Hacker News articles and return the title and url.
6061
""",
62+
agent_settings={"llm": "gpt-4.1"},
6163
structured_output_json=SearchResult,
6264
)
6365

examples/async_run.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ async def run_regular_task() -> None:
1616
regular_result = await client.tasks.run(
1717
task="""
1818
Find top 10 Hacker News articles and return the title and url.
19-
"""
19+
""",
20+
agent_settings={"llm": "gemini-2.5-flash"},
2021
)
2122

2223
print(f"Regular Task ID: {regular_result.id}")
@@ -39,6 +40,7 @@ class SearchResult(BaseModel):
3940
task="""
4041
Find top 10 Hacker News articles and return the title and url.
4142
""",
43+
agent_settings={"llm": "gpt-4.1"},
4244
structured_output_json=SearchResult,
4345
)
4446

examples/async_stream.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class SearchResult(BaseModel):
4848
task="""
4949
Find top 10 Hacker News articles and return the title and url.
5050
""",
51+
agent_settings={"llm": "gpt-4.1"},
5152
structured_output_json=SearchResult,
5253
)
5354

examples/create.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def create_regular_task() -> None:
1515
res = client.tasks.create(
1616
task="""
1717
Find top 10 Hacker News articles and return the title and url.
18-
"""
18+
""",
19+
agent_settings={"llm": "gemini-2.5-flash"},
1920
)
2021

2122
print(res.id)
@@ -37,6 +38,7 @@ class SearchResult(BaseModel):
3738
task="""
3839
Find top 10 Hacker News articles and return the title and url.
3940
""",
41+
agent_settings={"llm": "gpt-4.1"},
4042
structured_output_json=SearchResult,
4143
)
4244

examples/retrieve.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def retrieve_regular_task() -> None:
2222
regular_task = client.tasks.create(
2323
task="""
2424
Find top 10 Hacker News articles and return the title and url.
25-
"""
25+
""",
26+
agent_settings={"llm": "gemini-2.5-flash"},
2627
)
2728

2829
print(f"Task ID: {regular_task.id}")
@@ -61,6 +62,7 @@ class SearchResult(BaseModel):
6162
task="""
6263
Find top 10 Hacker News articles and return the title and url.
6364
""",
65+
agent_settings={"llm": "gpt-4.1"},
6466
structured_output_json=SearchResult,
6567
)
6668

0 commit comments

Comments
 (0)