Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chatty-pans-create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand-evals": patch
---

Paramaterize execution model in agent evals
5 changes: 5 additions & 0 deletions .changeset/curly-boats-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand-evals": patch
---

improve evals screenshot service - add img hashing diff to add screenshots and change to screenshot intercepts from the agent
5 changes: 5 additions & 0 deletions .changeset/dark-crabs-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand-evals": minor
---

added web voyager ground truth (optional), added web bench, and subset of OSWorld evals which run on a browser
5 changes: 5 additions & 0 deletions .changeset/few-frogs-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Pass stagehand object to agent instead of stagehand page
5 changes: 5 additions & 0 deletions .changeset/icy-toes-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Add playwright arguments to agent execute response
5 changes: 5 additions & 0 deletions .changeset/loud-waves-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

adds support for stagehand agent in the api
5 changes: 5 additions & 0 deletions .changeset/many-rats-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Fix for zod peer dependency support
5 changes: 5 additions & 0 deletions .changeset/purple-squids-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Fixed info logs on api session create
5 changes: 5 additions & 0 deletions .changeset/tasty-candles-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Improve failed act error logs
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ EXPERIMENTAL_EVAL_MODELS="gpt-4o,claude-3-5-sonnet-latest,o1-mini,o1-preview"
EVAL_CATEGORIES="observe,act,combination,extract,experimental"
AGENT_EVAL_MAX_STEPS=50
STAGEHAND_API_URL="http://localhost:80"
AGENT_EVAL_EXECUTION_MODEL="google/gemini-2.5-flash
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CLAUDE.md
node_modules/
/test-results/
/playwright-report/
Expand Down
20 changes: 4 additions & 16 deletions docs/configuration/browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ stagehand = Stagehand(
apiKey: process.env.BROWSERBASE_API_KEY,
projectId: process.env.BROWSERBASE_PROJECT_ID,
browserbaseSessionCreateParams: {
projectId: process.env.BROWSERBASE_PROJECT_ID!,
projectId: process.env.BROWSERBASE_PROJECT_ID!, // Optional: automatically set if given in environment variable or by Stagehand parameter
proxies: true,
region: "us-west-2",
timeout: 3600, // 1 hour session timeout
Expand All @@ -124,17 +124,11 @@ stagehand = Stagehand(
blockAds: true,
solveCaptchas: true,
recordSession: false,
os: "windows", // Valid: "windows" | "mac" | "linux" | "mobile" | "tablet"
viewport: {
width: 1920,
height: 1080,
},
fingerprint: {
browsers: ["chrome", "edge"],
devices: ["desktop"],
operatingSystems: ["windows", "macos"],
locales: ["en-US", "en-GB"],
httpVersion: 2,
},
},
userMetadata: {
userId: "automation-user-123",
Expand All @@ -149,7 +143,7 @@ stagehand = Stagehand(
api_key=os.getenv("BROWSERBASE_API_KEY"),
project_id=os.getenv("BROWSERBASE_PROJECT_ID"),
browserbase_session_create_params={
"project_id": os.getenv("BROWSERBASE_PROJECT_ID"),
"project_id": os.getenv("BROWSERBASE_PROJECT_ID"), # Optional: automatically set if given in environment or by Stagehand parameter
"proxies": True,
"region": "us-west-2",
"timeout": 3600, # 1 hour session timeout
Expand All @@ -159,17 +153,11 @@ stagehand = Stagehand(
"block_ads": True,
"solve_captchas": True,
"record_session": False,
"os": "windows", # "windows" | "mac" | "linux" | "mobile" | "tablet"
"viewport": {
"width": 1920,
"height": 1080,
},
"fingerprint": {
"browsers": ["chrome", "edge"],
"devices": ["desktop"],
"operating_systems": ["windows", "macos"],
"locales": ["en-US", "en-GB"],
"http_version": 2,
},
},
"user_metadata": {
"user_id": "automation-user-123",
Expand Down
43 changes: 33 additions & 10 deletions docs/configuration/models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,47 +156,70 @@ stagehand = Stagehand(
## Custom LLM Integration

<Note>
Custom LLMs are currently only supported in TypeScript.
Only [LiteLLM compatible providers](https://docs.litellm.ai/docs/providers) are available in Python. Some may require extra setup.
</Note>

Integrate any LLM with Stagehand using custom clients. The only requirement is **structured output support** for consistent automation behavior.

### Vercel AI SDK
The [Vercel AI SDK](https://sdk.vercel.ai/providers/ai-sdk-providers) is a popular library for interacting with LLMs. You can use any of the providers supported by the Vercel AI SDK to create a client for your model, **as long as they support structured outputs**.

Vercel AI SDK supports providers for OpenAI, Anthropic, and Google, along with support for **Amazon Bedrock** and **Azure OpenAI**.
Vercel AI SDK supports providers for OpenAI, Anthropic, and Google, along with support for **Amazon Bedrock** and **Azure OpenAI**. For a full list, see the [Vercel AI SDK providers page](https://sdk.vercel.ai/providers/ai-sdk-providers).

To get started, you'll need to install the `ai` package and the provider you want to use. For example, to use Amazon Bedrock, you'll need to install the `@ai-sdk/amazon-bedrock` package.
To get started, you'll need to install the `ai` package (version 4) and the provider you want to use (version 1 - both need to be compatible with LanguageModelV1). For example, to use Amazon Bedrock, you'll need to install the `@ai-sdk/amazon-bedrock` package.

You'll also need to use the [Vercel AI SDK external client](https://github.com/browserbase/stagehand/blob/main/examples/external_clients/aisdk.ts) as a template to create a client for your model.
You'll also need to import the [Vercel AI SDK external client](https://github.com/browserbase/stagehand/blob/main/lib/llm/aisdk.ts) through Stagehand to create a client for your model.

<Tabs>
<Tab title="npm">
```bash
npm install ai @ai-sdk/amazon-bedrock
npm install ai@4 @ai-sdk/amazon-bedrock@1
```
</Tab>

<Tab title="pnpm">
```bash
pnpm install ai @ai-sdk/amazon-bedrock
pnpm install ai@4 @ai-sdk/amazon-bedrock@1
```
</Tab>

<Tab title="yarn">
```bash
yarn add ai @ai-sdk/amazon-bedrock
yarn add ai@4 @ai-sdk/amazon-bedrock@1
```
</Tab>
</Tabs>

To get started, you can use the [Vercel AI SDK external client](https://github.com/browserbase/stagehand/blob/84f810b4631291307a32a47addad7e26e9c1deb3/examples/external_clients/aisdk.ts) as a template to create a client for your model.
<Note>
The `AISdkClient` is not yet available via the Stagehand npm package. For now, install Stagehand as a git repository to access the `AISdkClient` (this will be included in the npm package in an upcoming release).
</Note>

<Tabs>
<Tab title="npm">
```bash
npm install @browserbasehq/stagehand@git+https://github.com/browserbase/stagehand.git
```
</Tab>

<Tab title="pnpm">
```bash
pnpm install @browserbasehq/stagehand@git+https://github.com/browserbase/stagehand.git
```
</Tab>

<Tab title="yarn">
```bash
yarn add @browserbasehq/stagehand@git+https://github.com/browserbase/stagehand.git
```
</Tab>
</Tabs>

```ts
// Install/import the provider you want to use.
// For example, to use OpenAI, import `openai` from @ai-sdk/openai
// For example, to use Azure OpenAI, import { createAzure } from '@ai-sdk/azure';
import { bedrock } from "@ai-sdk/amazon-bedrock";
import { AISdkClient } from "./external_clients/aisdk";
// @ts-ignore
import { AISdkClient } from "@browserbasehq/stagehand";

const stagehand = new Stagehand({
llmClient: new AISdkClient({
Expand Down
38 changes: 29 additions & 9 deletions docs/first-steps/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ main().catch((err) => {

<Tab title="Python">

<Tip>
For uv installation instructions see the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_1).
</Tip>

### Initialize virtual environment

<CodeGroup>

```bash uv
uv init my-stagehand-project
cd my-stagehand-project
```

```bash pip
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```

</CodeGroup>

### Add dependencies

<CodeGroup>
Expand Down Expand Up @@ -128,6 +148,10 @@ BROWSERBASE_PROJECT_ID=your_project_id
import os
import asyncio
from stagehand import Stagehand
from pydantic import BaseModel

class PageData(BaseModel):
title: str

async def main():
stagehand = Stagehand(
Expand All @@ -143,16 +167,12 @@ async def main():
await page.act("Click the sign in button")

# Extract structured data
result = await page.extract({
"instruction": "extract the page title",
"schema": {
"title": {
"type": "string"
}
}
})
result = await page.extract(
instruction = "extract the page title",
schema = PageData
)

print(result["title"])
print(result.title)
await stagehand.close()

if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion evals/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ function handleRun(args: string[]): void {
webbench: "agent/webbench",
gaia: "agent/gaia",
webvoyager: "agent/webvoyager",
osworld: "agent/osworld",
onlineMind2Web: "agent/onlineMind2Web",
};

Expand Down
Loading