Skip to main content
Want a ready-made UI? See the Chat UI tutorial.
Stream messages as the agent works — reasoning, tool calls, browser actions, and results. Each message has role, type, summary, data, and screenshot_url. See List session messages for all fields.
from browser_use_sdk.v3 import AsyncBrowserUse

client = AsyncBrowserUse()

run = client.run("Find the top story on Hacker News")
async for msg in run:
    print(f"[{msg.role}] {msg.summary}")

print(run.result.output)
import { BrowserUse } from "browser-use-sdk/v3";

const client = new BrowserUse();

const run = client.run("Find the top story on Hacker News");
for await (const msg of run) {
  console.log(`[${msg.role}] ${msg.summary}`);
}

console.log(run.result.output);
[user] Find the top story on Hacker News
[assistant] Navigating to https://news.ycombinator.com/
[tool] Browser Navigate: Navigated
[assistant] Analyzing browser state
[tool] Browser Analyze State: The top story is "Coding Agents Could Make Free Software Matter Again"
[tool] Done Autonomous: The top story on Hacker News is "Coding Agents Could Make Free Software Matter Again"

Manual polling

If you need full control over the polling loop (e.g. custom interval, filtering):
import asyncio
from browser_use_sdk.v3 import AsyncBrowserUse

client = AsyncBrowserUse()
session = await client.sessions.create(task="Find the top story on Hacker News")

cursor = None
while True:
    msgs = await client.sessions.messages(session.id, after=cursor, limit=100)
    for m in msgs.messages:
        print(f"[{m.role}] {m.summary}")
        cursor = m.id

    s = await client.sessions.get(session.id)
    if s.status.value in ("idle", "stopped", "error", "timed_out"):
        break
    await asyncio.sleep(2)

print(s.output)
import { BrowserUse } from "browser-use-sdk/v3";

const client = new BrowserUse();
const session = await client.sessions.create({
  task: "Find the top story on Hacker News",
});

let cursor: string | undefined;
while (true) {
  const msgs = await client.sessions.messages(session.id, { after: cursor, limit: 100 });
  for (const m of msgs.messages) {
    console.log(`[${m.role}] ${m.summary}`);
    cursor = m.id;
  }

  const s = await client.sessions.get(session.id);
  if (["idle", "stopped", "error", "timed_out"].includes(s.status)) {
    console.log(s.output);
    break;
  }
  await new Promise((r) => setTimeout(r, 2000));
}