@@ -16,11 +16,14 @@ from browser_use_sdk import BrowserUse
16
16
17
17
client = BrowserUse(api_key = " bu_..." )
18
18
19
- result = client.tasks.run (
19
+ task = client.tasks.create_task (
20
20
task = " Search for the top 10 Hacker News posts and return the title and url."
21
+ llm = " gpt-4.1" ,
21
22
)
22
23
23
- result.done_output
24
+ result = task.complete()
25
+
26
+ result.output
24
27
```
25
28
26
29
> The full API of this library can be found in [ api.md] ( api.md ) .
@@ -38,16 +41,18 @@ class SearchResult(BaseModel):
38
41
posts: List[HackerNewsPost]
39
42
40
43
async def main () -> None :
41
- result = await client.tasks.run (
44
+ task = await client.tasks.create_task (
42
45
task = """
43
46
Find top 10 Hacker News articles and return the title and url.
44
47
""" ,
45
- structured_output_json = SearchResult,
48
+ schema = SearchResult,
46
49
)
47
50
48
- if structured_result.parsed_output is not None :
51
+ result = await task.complete()
52
+
53
+ if result.parsed_output is not None :
49
54
print (" Top HackerNews Posts:" )
50
- for post in structured_result .parsed_output.posts:
55
+ for post in result .parsed_output.posts:
51
56
print (f " - { post.title} - { post.url} " )
52
57
53
58
asyncio.run(main())
@@ -73,25 +78,18 @@ async def main() -> None:
73
78
task = """
74
79
Find top 10 Hacker News articles and return the title and url.
75
80
""" ,
76
- structured_output_json = SearchResult,
81
+ schema = SearchResult,
77
82
)
78
83
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} ) " )
85
86
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()
93
88
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} " )
95
93
96
94
asyncio.run(main())
97
95
```
@@ -105,7 +103,7 @@ Browser Use SDK lets you easily verify the signature and structure of the payloa
105
103
``` py
106
104
import uvicorn
107
105
import 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
109
107
110
108
from fastapi import FastAPI, Request, HTTPException
111
109
@@ -153,10 +151,11 @@ client = AsyncBrowserUse(
153
151
154
152
155
153
async def main () -> None :
156
- task = await client.tasks.run (
154
+ task = await client.tasks.create_task (
157
155
task = " Search for the top 10 Hacker News posts and return the title and url." ,
158
156
)
159
- print (task.done_output)
157
+
158
+ print (task.id)
160
159
161
160
162
161
asyncio.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
468
467
an issue first to discuss with us!
469
468
470
469
On the other hand, contributions to the README are always very welcome!
470
+
471
471
## Installation
472
472
473
473
``` sh
@@ -530,4 +530,3 @@ except ApiError as e:
530
530
print (e.status_code)
531
531
print (e.body)
532
532
```
533
-
0 commit comments