Pass a Pydantic model (Python) or Zod schema (TypeScript) — result.output is automatically validated and converted to the typed object.
TypeScript requires Zod v4 (npm install zod@4). Zod v3 is not compatible.
from browser_use_sdk.v3 import AsyncBrowserUse
from pydantic import BaseModel
class Post(BaseModel):
name: str
points: int
comments: int
class HNPosts(BaseModel):
posts: list[Post]
client = AsyncBrowserUse()
result = await client.run(
"List the top 20 posts on Hacker News today with their points",
output_schema=HNPosts,
)
for post in result.output.posts:
print(f"{post.name} ({post.points} pts, {post.comments} comments)")
Scrape multiple sites concurrently
Each client.run() call creates its own session, so you can run them in parallel with asyncio.gather (Python) or Promise.all (TypeScript). Every result is fully typed.
import asyncio
from browser_use_sdk.v3 import AsyncBrowserUse
from pydantic import BaseModel
class Product(BaseModel):
name: str
price: str
url: str
class Results(BaseModel):
products: list[Product]
async def main():
client = AsyncBrowserUse()
sites = [
"Find the top 3 laptops on amazon.com with their prices",
"Find the top 3 laptops on bestbuy.com with their prices",
"Find the top 3 laptops on newegg.com with their prices",
]
results = await asyncio.gather(*[
client.run(task, output_schema=Results)
for task in sites
])
for result in results:
for p in result.output.products:
print(f"{p.name} — {p.price}")
asyncio.run(main())