- Stagehand + Vercel AI SDK
Get your API keys
You’ll need credentials from two services:Browserbase — Go to the Dashboard Settings and copy your API key and project ID.
Anthropic — Get your API key from the Anthropic Console.Create a

.env.local file with:Install dependencies
| Package | Purpose |
|---|---|
@browserbasehq/stagehand | AI-powered browser automation |
@browserbasehq/sdk | Browserbase API client (sessions, live views) |
ai | Vercel AI SDK for structured generation |
@ai-sdk/anthropic | Anthropic model provider |
zod | Schema validation for extracted data |
Create a Stagehand session
Initialize a Stagehand instance connected to Browserbase. Each session gets its own cloud browser with a live debug view.
Define research functions
Each research function takes a Stagehand instance, navigates to a source, and uses You can create similar functions for Wikipedia, YouTube, Hacker News, and Google News — each using
stagehand.extract() to pull structured data from the page using AI.Here’s an example that searches DuckDuckGo and visits top results:stagehand.extract() with different schemas. See the full template for all five research functions.Create the API route with SSE streaming
Create
app/api/research/route.ts to handle research requests. This route creates parallel Stagehand sessions and streams findings back via Server-Sent Events.Full Template on GitHub
Browse the complete source code with frontend components, SSE streaming, and live browser views.
Deploy to Vercel
One-click deploy with automatic Browserbase setup via the Vercel Marketplace.