Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<ul style="list-style: none; margin: 0; padding: 0;">
<a href="https://stagehand.dev">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="media/dark_logo.png" />
<img alt="Stagehand" src="media/light_logo.png" width="200" style="margin-right: 30px;" />
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/browserbase/stagehand/main/media/dark_logo.png" />
<img alt="Stagehand" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/light_logo.png" width="200" style="margin-right: 30px;" />
</picture>
</a>
</ul>
Expand All @@ -16,14 +16,14 @@
<p align="center">
<a href="https://github.com/browserbase/stagehand/tree/main?tab=MIT-1-ov-file#MIT-1-ov-file">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="media/dark_license.svg" />
<img alt="MIT License" src="media/light_license.svg" />
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/browserbase/stagehand/main/media/dark_license.svg" />
<img alt="MIT License" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/light_license.svg" />
</picture>
</a>
<a href="https://stagehand.dev/discord">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="media/dark_discord.svg" />
<img alt="Discord Community" src="media/light_discord.svg" />
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/browserbase/stagehand/main/media/dark_discord.svg" />
<img alt="Discord Community" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/light_discord.svg" />
</picture>
</a>
</p>
Expand All @@ -45,7 +45,7 @@ If you're looking for other languages, you can find them
</a>
<span> </span>
<picture>
<img alt="Director" src="media/director_icon.svg" width="25" />
<img alt="Director" src="https://raw.githubusercontent.com/browserbase/stagehand/main/media/director_icon.svg" width="25" />
</picture>
</div>

Expand Down Expand Up @@ -162,7 +162,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
// - BROWSERBASE_PROJECT_ID
// - A model API key (OPENAI_API_KEY, ANTHROPIC_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY, etc.)

// 1. Connect to Stagehand cloud API (uses STAGEHAND_API_URL env var or default)
// 1. Connect to Stagehand cloud API (uses STAGEHAND_BASE_URL env var or default)
let mut stagehand = Stagehand::connect(TransportChoice::default_rest()).await?;

// 2. Start session
Expand Down Expand Up @@ -247,7 +247,7 @@ CEREBRAS_API_KEY=your_cerebras_key # Cerebras
DEEPSEEK_API_KEY=your_deepseek_key # DeepSeek

# Optional: Custom API URLs
STAGEHAND_API_URL=https://api.stagehand.browserbase.com/v1 # Stagehand API (default)
STAGEHAND_BASE_URL=https://api.stagehand.browserbase.com/v1 # Stagehand API (default)
BROWSERBASE_API_URL=https://api.browserbase.com/v1 # Browserbase API (default)
```

Expand Down Expand Up @@ -317,12 +317,12 @@ pub async fn connect(

**Parameters:**

- `transport_choice` - `TransportChoice::Rest(base_url)` for REST API with explicit URL, or use `TransportChoice::default_rest()` to use the `STAGEHAND_API_URL` env var (falls back to default)
- `transport_choice` - `TransportChoice::Rest(base_url)` for REST API with explicit URL, or use `TransportChoice::default_rest()` to use the `STAGEHAND_BASE_URL` env var (falls back to default)

**Example:**

```rust
// Using default (recommended) - checks STAGEHAND_API_URL env var, falls back to default
// Using default (recommended) - checks STAGEHAND_BASE_URL env var, falls back to default
let stagehand = Stagehand::connect(TransportChoice::default_rest()).await?;

// Or with explicit URL
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub struct V3Options {
// =============================================================================

/// Default Stagehand API URL
pub const DEFAULT_STAGEHAND_API_URL: &str = "https://api.stagehand.browserbase.com/v1";
pub const DEFAULT_STAGEHAND_BASE_URL: &str = "https://api.stagehand.browserbase.com/v1";

/// Default Browserbase API URL
pub const DEFAULT_BROWSERBASE_API_URL: &str = "https://api.browserbase.com/v1";
Expand All @@ -282,11 +282,11 @@ pub enum TransportChoice {
}

impl TransportChoice {
/// Create a REST transport using the URL from `STAGEHAND_API_URL` environment variable,
/// Create a REST transport using the URL from `STAGEHAND_BASE_URL` environment variable,
/// or fall back to the default Stagehand API URL if not set.
pub fn default_rest() -> Self {
let base_url = std::env::var("STAGEHAND_API_URL")
.unwrap_or_else(|_| DEFAULT_STAGEHAND_API_URL.to_string());
let base_url = std::env::var("STAGEHAND_BASE_URL")
.unwrap_or_else(|_| DEFAULT_STAGEHAND_BASE_URL.to_string());
TransportChoice::Rest(base_url)
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/browserbase_live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async fn test_browserbase_live() -> Result<(), Box<dyn std::error::Error + Send
// Load environment variables from .env
dotenvy::dotenv().ok();

// 1. Create client, specifying REST transport (uses STAGEHAND_API_URL env var or default)
// 1. Create client, specifying REST transport (uses STAGEHAND_BASE_URL env var or default)
let mut stagehand = Stagehand::connect(TransportChoice::default_rest()).await?;

// 2. Configure V3 Options
Expand Down
Loading