Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.2.0"
".": "0.3.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 26
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-ce018db4d6891d645cfb220c86d17ac1d431e1ba2f604e8015876b17a5a11149.yml
openapi_spec_hash: e9a00924682ab214ca5d8b6b5c84430e
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browser-use%2Fbrowser-use-814bdd9f98b750d42a2b713a0a12b14fc5a0241ff820b2fbc7666ab2e9a5443f.yml
openapi_spec_hash: 0dae4d4d33a3ec93e470f9546e43fad3
config_hash: dd3e22b635fa0eb9a7c741a8aaca2a7f
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.3.0 (2025-08-20)

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

### Features

* LLM key strings over LLM model enum ([0f5930a](https://github.com/browser-use/browser-use-python/commit/0f5930a7760190523f1d3e969c66e0a34ff075b3))

## 0.2.0 (2025-08-19)

Full Changelog: [v0.1.0...v0.2.0](https://github.com/browser-use/browser-use-python/compare/v0.1.0...v0.2.0)
Expand Down
1 change: 0 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Types:
```python
from browser_use_sdk.types import (
FileView,
LlmModel,
TaskItemView,
TaskStatus,
TaskStepView,
Expand Down
55 changes: 55 additions & 0 deletions examples/async_create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env -S rye run python

import asyncio
from typing import List

from pydantic import BaseModel

from browser_use_sdk import AsyncBrowserUse

# gets API Key from environment variable BROWSER_USE_API_KEY
client = AsyncBrowserUse()


# Regular Task
async def create_regular_task() -> None:
res = await client.tasks.create(
task="""
Find top 10 Hacker News articles and return the title and url.
"""
)

print(f"Regular Task ID: {res.id}")


# Structured Output
async def create_structured_task() -> None:
class HackerNewsPost(BaseModel):
title: str
url: str

class SearchResult(BaseModel):
posts: List[HackerNewsPost]

res = await client.tasks.create(
task="""
Find top 10 Hacker News articles and return the title and url.
""",
structured_output_json=SearchResult,
)

print(f"Structured Task ID: {res.id}")


# Main


async def main() -> None:
await asyncio.gather(
#
create_regular_task(),
create_structured_task(),
)


asyncio.run(main())
95 changes: 95 additions & 0 deletions examples/async_retrieve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/usr/bin/env -S rye run python

import asyncio
from typing import List

from pydantic import BaseModel

from browser_use_sdk import AsyncBrowserUse

# gets API Key from environment variable BROWSER_USE_API_KEY
client = AsyncBrowserUse()


# Regular Task
async def retrieve_regular_task() -> None:
"""
Retrieves a regular task and waits for it to finish.
"""

print("Retrieving regular task...")

regular_task = await client.tasks.create(
task="""
Find top 10 Hacker News articles and return the title and url.
"""
)

print(f"Regular Task ID: {regular_task.id}")

while True:
regular_status = await client.tasks.retrieve(regular_task.id)
print(f"Regular Task Status: {regular_status.status}")
if regular_status.status == "finished":
print(f"Regular Task Output: {regular_status.done_output}")
break

await asyncio.sleep(1)

print("Done")


async def retrieve_structured_task() -> None:
"""
Retrieves a structured task and waits for it to finish.
"""

print("Retrieving structured task...")

# Structured Output
class HackerNewsPost(BaseModel):
title: str
url: str

class SearchResult(BaseModel):
posts: List[HackerNewsPost]

structured_task = await client.tasks.create(
task="""
Find top 10 Hacker News articles and return the title and url.
""",
structured_output_json=SearchResult,
)

print(f"Structured Task ID: {structured_task.id}")

while True:
structured_status = await client.tasks.retrieve(task_id=structured_task.id, structured_output_json=SearchResult)
print(f"Structured Task Status: {structured_status.status}")

if structured_status.status == "finished":
if structured_status.parsed_output is None:
print("Structured Task No output")
else:
for post in structured_status.parsed_output.posts:
print(f" - {post.title} - {post.url}")

break

await asyncio.sleep(1)

print("Done")


# Main


async def main() -> None:
await asyncio.gather(
#
retrieve_regular_task(),
retrieve_structured_task(),
)


asyncio.run(main())
63 changes: 63 additions & 0 deletions examples/async_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env -S rye run python

import asyncio
from typing import List

from pydantic import BaseModel

from browser_use_sdk import AsyncBrowserUse

# gets API Key from environment variable BROWSER_USE_API_KEY
client = AsyncBrowserUse()


# Regular Task
async def run_regular_task() -> None:
regular_result = await client.tasks.run(
task="""
Find top 10 Hacker News articles and return the title and url.
"""
)

print(f"Regular Task ID: {regular_result.id}")

print(f"Regular Task Output: {regular_result.done_output}")

print("Done")


# Structured Output
async def run_structured_task() -> None:
class HackerNewsPost(BaseModel):
title: str
url: str

class SearchResult(BaseModel):
posts: List[HackerNewsPost]

structured_result = await client.tasks.run(
task="""
Find top 10 Hacker News articles and return the title and url.
""",
structured_output_json=SearchResult,
)

print(f"Structured Task ID: {structured_result.id}")

if structured_result.parsed_output is not None:
print("Structured Task Output:")
for post in structured_result.parsed_output.posts:
print(f" - {post.title} - {post.url}")

print("Structured Task Done")


async def main() -> None:
await asyncio.gather(
#
run_regular_task(),
run_structured_task(),
)


asyncio.run(main())
81 changes: 81 additions & 0 deletions examples/async_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env -S rye run python

import asyncio
from typing import List

from pydantic import BaseModel

from browser_use_sdk import AsyncBrowserUse
from browser_use_sdk.types.task_create_params import AgentSettings

# gets API Key from environment variable BROWSER_USE_API_KEY
client = AsyncBrowserUse()


# Regular Task
async def stream_regular_task() -> None:
regular_task = await client.tasks.create(
task="""
Find top 10 Hacker News articles and return the title and url.
""",
agent_settings=AgentSettings(llm="gemini-2.5-flash"),
)

print(f"Regular Task ID: {regular_task.id}")

async for res in client.tasks.stream(regular_task.id):
print(f"Regular Task Status: {res.status}")

if len(res.steps) > 0:
last_step = res.steps[-1]
print(f"Regular Task Step: {last_step.url} ({last_step.next_goal})")
for action in last_step.actions:
print(f" - Regular Task Action: {action}")

print("Regular Task Done")


# Structured Output
async def stream_structured_task() -> None:
class HackerNewsPost(BaseModel):
title: str
url: str

class SearchResult(BaseModel):
posts: List[HackerNewsPost]

structured_task = await client.tasks.create(
task="""
Find top 10 Hacker News articles and return the title and url.
""",
structured_output_json=SearchResult,
)

print(f"Structured Task ID: {structured_task.id}")

async for res in client.tasks.stream(structured_task.id, structured_output_json=SearchResult):
print(f"Structured Task Status: {res.status}")

if res.status == "finished":
if res.parsed_output is None:
print("Structured Task No output")
else:
for post in res.parsed_output.posts:
print(f" - Structured Task Post: {post.title} - {post.url}")
break

print("Structured Task Done")


# Main


async def main() -> None:
await asyncio.gather(
#
stream_regular_task(),
stream_structured_task(),
)


asyncio.run(main())
46 changes: 46 additions & 0 deletions examples/create.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env -S rye run python

from typing import List

from pydantic import BaseModel

from browser_use_sdk import BrowserUse

# gets API Key from environment variable BROWSER_USE_API_KEY
client = BrowserUse()


# Regular Task
def create_regular_task() -> None:
res = client.tasks.create(
task="""
Find top 10 Hacker News articles and return the title and url.
"""
)

print(res.id)


create_regular_task()


# Structured Output
def create_structured_task() -> None:
class HackerNewsPost(BaseModel):
title: str
url: str

class SearchResult(BaseModel):
posts: List[HackerNewsPost]

res = client.tasks.create(
task="""
Find top 10 Hacker News articles and return the title and url.
""",
structured_output_json=SearchResult,
)

print(res.id)


create_structured_task()
Loading