@@ -16,11 +16,14 @@ from browser_use_sdk import BrowserUse
1616
1717client = BrowserUse(api_key = " bu_..." )
1818
19- result = client.tasks.run (
19+ task = client.tasks.create_task (
2020 task = " Search for the top 10 Hacker News posts and return the title and url."
21+ llm = " gpt-4.1" ,
2122)
2223
23- result.done_output
24+ result = task.complete()
25+
26+ result.output
2427```
2528
2629> The full API of this library can be found in [ api.md] ( api.md ) .
@@ -38,16 +41,18 @@ class SearchResult(BaseModel):
3841 posts: List[HackerNewsPost]
3942
4043async def main () -> None :
41- result = await client.tasks.run (
44+ task = await client.tasks.create_task (
4245 task = """
4346 Find top 10 Hacker News articles and return the title and url.
4447 """ ,
45- structured_output_json = SearchResult,
48+ schema = SearchResult,
4649 )
4750
48- if structured_result.parsed_output is not None :
51+ result = await task.complete()
52+
53+ if result.parsed_output is not None :
4954 print (" Top HackerNews Posts:" )
50- for post in structured_result .parsed_output.posts:
55+ for post in result .parsed_output.posts:
5156 print (f " - { post.title} - { post.url} " )
5257
5358asyncio.run(main())
@@ -73,25 +78,18 @@ async def main() -> None:
7378 task = """
7479 Find top 10 Hacker News articles and return the title and url.
7580 """ ,
76- structured_output_json = SearchResult,
81+ schema = SearchResult,
7782 )
7883
79- async for update in client.tasks.stream(task.id, structured_output_json = SearchResult):
80- if len (update.steps) > 0 :
81- last_step = update.steps[- 1 ]
82- print (f " { update.status} : { last_step.url} ( { last_step.next_goal} ) " )
83- else :
84- print (f " { update.status} " )
84+ async for step in task.stream():
85+ print (f " Step { step.number} : { step.url} ( { step.next_goal} ) " )
8586
86- if update.status == " finished" :
87- if update.parsed_output is None :
88- print (" No output..." )
89- else :
90- print (" Top HackerNews Posts:" )
91- for post in update.parsed_output.posts:
92- print (f " - { post.title} - { post.url} " )
87+ result = await task.complete()
9388
94- break
89+ if result.parsed_output is not None :
90+ print (" Top HackerNews Posts:" )
91+ for post in result.parsed_output.posts:
92+ print (f " - { post.title} - { post.url} " )
9593
9694asyncio.run(main())
9795```
@@ -105,7 +103,7 @@ Browser Use SDK lets you easily verify the signature and structure of the payloa
105103``` py
106104import uvicorn
107105import os
108- from browser_use_sdk.lib.webhooks import Webhook, verify_webhook_event_signature
106+ from browser_use_sdk import Webhook, verify_webhook_event_signature
109107
110108from fastapi import FastAPI, Request, HTTPException
111109
@@ -153,10 +151,11 @@ client = AsyncBrowserUse(
153151
154152
155153async def main () -> None :
156- task = await client.tasks.run (
154+ task = await client.tasks.create_task (
157155 task = " Search for the top 10 Hacker News posts and return the title and url." ,
158156 )
159- print (task.done_output)
157+
158+ print (task.id)
160159
161160
162161asyncio.run(main())
@@ -468,6 +467,7 @@ a proof of concept, but know that we will not be able to merge it as-is. We sugg
468467an issue first to discuss with us!
469468
470469On the other hand, contributions to the README are always very welcome!
470+
471471## Installation
472472
473473``` sh
@@ -530,4 +530,3 @@ except ApiError as e:
530530 print (e.status_code)
531531 print (e.body)
532532```
533-
0 commit comments