API Reference
Start a new browser session
Creates a new browser session with the specified configuration. Returns a session ID used for all subsequent operations.
POST
/
v1
/
sessions
/
start
JavaScript
import Stagehand from 'stagehand-sdk';
const client = new Stagehand({
browserbaseAPIKey: process.env['BROWSERBASE_API_KEY'], // This is the default and can be omitted
browserbaseProjectID: process.env['BROWSERBASE_PROJECT_ID'], // This is the default and can be omitted
modelAPIKey: process.env['MODEL_API_KEY'], // This is the default and can be omitted
});
const response = await client.sessions.start({ modelName: 'openai/gpt-5.4-mini' });
console.log(response.data);import os
from stagehand import Stagehand
client = Stagehand(
browserbase_api_key=os.environ.get("BROWSERBASE_API_KEY"), # This is the default and can be omitted
browserbase_project_id=os.environ.get("BROWSERBASE_PROJECT_ID"), # This is the default and can be omitted
model_api_key=os.environ.get("MODEL_API_KEY"), # This is the default and can be omitted
)
response = client.sessions.start(
model_name="openai/gpt-5.4-mini",
)
print(response.data)package main
import (
"context"
"fmt"
"github.com/browserbase/stagehand-go"
"github.com/browserbase/stagehand-go/option"
)
func main() {
client := stagehand.NewClient(
option.WithBrowserbaseAPIKey("My Browserbase API Key"),
option.WithBrowserbaseProjectID("My Browserbase Project ID"),
option.WithModelAPIKey("My Model API Key"),
)
response, err := client.Sessions.Start(context.TODO(), stagehand.SessionStartParams{
ModelName: "openai/gpt-5.4-mini",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}package com.browserbase.api.example;
import com.browserbase.api.client.StagehandClient;
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
import com.browserbase.api.models.sessions.SessionStartParams;
import com.browserbase.api.models.sessions.SessionStartResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StagehandClient client = StagehandOkHttpClient.fromEnv();
SessionStartParams params = SessionStartParams.builder()
.modelName("openai/gpt-5.4-mini")
.build();
SessionStartResponse response = client.sessions().start(params);
}
}package com.browserbase.api.example
import com.browserbase.api.client.StagehandClient
import com.browserbase.api.client.okhttp.StagehandOkHttpClient
import com.browserbase.api.models.sessions.SessionStartParams
import com.browserbase.api.models.sessions.SessionStartResponse
fun main() {
val client: StagehandClient = StagehandOkHttpClient.fromEnv()
val params: SessionStartParams = SessionStartParams.builder()
.modelName("openai/gpt-5.4-mini")
.build()
val response: SessionStartResponse = client.sessions().start(params)
}require "stagehand"
stagehand = Stagehand::Client.new(
browserbase_api_key: "My Browserbase API Key",
browserbase_project_id: "My Browserbase Project ID",
model_api_key: "My Model API Key"
)
response = stagehand.sessions.start(model_name: "openai/gpt-5.4-mini")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Stagehand\Client;
use Stagehand\Core\Exceptions\APIException;
$client = new Client(
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: 'My Browserbase API Key',
browserbaseProjectID: getenv(
'BROWSERBASE_PROJECT_ID'
) ?: 'My Browserbase Project ID',
modelAPIKey: getenv('MODEL_API_KEY') ?: 'My Model API Key',
);
try {
$response = $client->sessions->start(
modelName: 'openai/gpt-5.4-mini',
actTimeoutMs: 0,
browser: [
'cdpURL' => 'ws://localhost:9222',
'launchOptions' => [
'acceptDownloads' => true,
'args' => ['string'],
'cdpHeaders' => ['foo' => 'string'],
'cdpURL' => 'cdpUrl',
'chromiumSandbox' => true,
'connectTimeoutMs' => 0,
'deviceScaleFactor' => 0,
'devtools' => true,
'downloadsPath' => 'downloadsPath',
'executablePath' => 'executablePath',
'hasTouch' => true,
'headless' => true,
'ignoreDefaultArgs' => true,
'ignoreHTTPSErrors' => true,
'locale' => 'locale',
'port' => 0,
'preserveUserDataDir' => true,
'proxy' => [
'server' => 'server',
'bypass' => 'bypass',
'password' => 'password',
'username' => 'username',
],
'userDataDir' => 'userDataDir',
'viewport' => ['height' => 0, 'width' => 0],
],
'type' => 'local',
],
browserbaseSessionCreateParams: [
'browserSettings' => [
'advancedStealth' => true,
'blockAds' => true,
'captchaImageSelector' => 'captchaImageSelector',
'captchaInputSelector' => 'captchaInputSelector',
'context' => ['id' => 'id', 'persist' => true],
'extensionID' => 'extensionId',
'fingerprint' => [
'browsers' => ['chrome'],
'devices' => ['desktop'],
'httpVersion' => '1',
'locales' => ['string'],
'operatingSystems' => ['android'],
'screen' => [
'maxHeight' => 0, 'maxWidth' => 0, 'minHeight' => 0, 'minWidth' => 0
],
],
'logSession' => true,
'os' => 'windows',
'recordSession' => true,
'solveCaptchas' => true,
'verified' => true,
'viewport' => ['height' => 0, 'width' => 0],
],
'extensionID' => 'extensionId',
'keepAlive' => true,
'projectID' => 'projectId',
'proxies' => true,
'region' => 'us-west-2',
'timeout' => 0,
'userMetadata' => ['foo' => 'bar'],
],
browserbaseSessionID: 'browserbaseSessionID',
domSettleTimeoutMs: 5000,
experimental: true,
selfHeal: true,
systemPrompt: 'systemPrompt',
verbose: 1,
waitForCaptchaSolves: true,
xStreamResponse: 'true',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using Stagehand;
using Stagehand.Models.Sessions;
StagehandClient client = new();
SessionStartParams parameters = new() { ModelName = "openai/gpt-5.4-mini" };
var response = await client.Sessions.Start(parameters);
Console.WriteLine(response);curl --request POST \
--url https://api.stagehand.browserbase.com/v1/sessions/start \
--header 'Content-Type: application/json' \
--header 'x-bb-api-key: <api-key>' \
--header 'x-bb-project-id: <api-key>' \
--data '
{
"modelName": "openai/gpt-5.4-mini",
"domSettleTimeoutMs": 5000,
"verbose": 1,
"systemPrompt": "<string>",
"browserbaseSessionCreateParams": {
"projectId": "<string>",
"browserSettings": {
"advancedStealth": true,
"blockAds": true,
"captchaImageSelector": "<string>",
"captchaInputSelector": "<string>",
"extensionId": "<string>",
"fingerprint": {
"browsers": [],
"devices": [],
"locales": [
"<string>"
],
"operatingSystems": [],
"screen": {
"maxHeight": 123,
"maxWidth": 123,
"minHeight": 123,
"minWidth": 123
}
},
"logSession": true,
"recordSession": true,
"solveCaptchas": true,
"verified": true,
"viewport": {
"width": 123,
"height": 123
}
},
"extensionId": "<string>",
"keepAlive": true,
"proxies": true,
"timeout": 123,
"userMetadata": {}
},
"browser": {
"type": "local",
"cdpUrl": "ws://localhost:9222",
"launchOptions": {
"args": [
"<string>"
],
"executablePath": "<string>",
"port": 123,
"userDataDir": "<string>",
"preserveUserDataDir": true,
"headless": true,
"devtools": true,
"chromiumSandbox": true,
"ignoreDefaultArgs": true,
"locale": "<string>",
"deviceScaleFactor": 123,
"hasTouch": true,
"ignoreHTTPSErrors": true,
"cdpUrl": "<string>",
"cdpHeaders": {},
"connectTimeoutMs": 123,
"downloadsPath": "<string>",
"acceptDownloads": true
}
},
"selfHeal": true,
"browserbaseSessionID": "<string>",
"experimental": true,
"waitForCaptchaSolves": true,
"actTimeoutMs": 123
}
'{
"success": true,
"data": {
"sessionId": "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
"available": true,
"cdpUrl": "wss://connect.browserbase.com/?signingKey=abc123"
}
}Authorizations
Browserbase API key for authentication
Deprecated. Browserbase API keys are now project-scoped, so this header is no longer required.
Headers
Whether to stream the response via SSE
Available options:
true, false Example:
"true"
Body
application/json
Model name to use for AI operations
Example:
"openai/gpt-5.4-mini"
Timeout in ms to wait for DOM to settle
Example:
5000
Logging verbosity level (0=quiet, 1=normal, 2=debug)
Available options:
0, 1, 2 Example:
1
Custom system prompt for AI operations
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Enable self-healing for failed actions
Example:
true
Existing Browserbase session ID to resume
Wait for captcha solves (deprecated, v2 only)
Timeout in ms for act operations (deprecated, v2 only)
⌘I
JavaScript
import Stagehand from 'stagehand-sdk';
const client = new Stagehand({
browserbaseAPIKey: process.env['BROWSERBASE_API_KEY'], // This is the default and can be omitted
browserbaseProjectID: process.env['BROWSERBASE_PROJECT_ID'], // This is the default and can be omitted
modelAPIKey: process.env['MODEL_API_KEY'], // This is the default and can be omitted
});
const response = await client.sessions.start({ modelName: 'openai/gpt-5.4-mini' });
console.log(response.data);import os
from stagehand import Stagehand
client = Stagehand(
browserbase_api_key=os.environ.get("BROWSERBASE_API_KEY"), # This is the default and can be omitted
browserbase_project_id=os.environ.get("BROWSERBASE_PROJECT_ID"), # This is the default and can be omitted
model_api_key=os.environ.get("MODEL_API_KEY"), # This is the default and can be omitted
)
response = client.sessions.start(
model_name="openai/gpt-5.4-mini",
)
print(response.data)package main
import (
"context"
"fmt"
"github.com/browserbase/stagehand-go"
"github.com/browserbase/stagehand-go/option"
)
func main() {
client := stagehand.NewClient(
option.WithBrowserbaseAPIKey("My Browserbase API Key"),
option.WithBrowserbaseProjectID("My Browserbase Project ID"),
option.WithModelAPIKey("My Model API Key"),
)
response, err := client.Sessions.Start(context.TODO(), stagehand.SessionStartParams{
ModelName: "openai/gpt-5.4-mini",
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}package com.browserbase.api.example;
import com.browserbase.api.client.StagehandClient;
import com.browserbase.api.client.okhttp.StagehandOkHttpClient;
import com.browserbase.api.models.sessions.SessionStartParams;
import com.browserbase.api.models.sessions.SessionStartResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
StagehandClient client = StagehandOkHttpClient.fromEnv();
SessionStartParams params = SessionStartParams.builder()
.modelName("openai/gpt-5.4-mini")
.build();
SessionStartResponse response = client.sessions().start(params);
}
}package com.browserbase.api.example
import com.browserbase.api.client.StagehandClient
import com.browserbase.api.client.okhttp.StagehandOkHttpClient
import com.browserbase.api.models.sessions.SessionStartParams
import com.browserbase.api.models.sessions.SessionStartResponse
fun main() {
val client: StagehandClient = StagehandOkHttpClient.fromEnv()
val params: SessionStartParams = SessionStartParams.builder()
.modelName("openai/gpt-5.4-mini")
.build()
val response: SessionStartResponse = client.sessions().start(params)
}require "stagehand"
stagehand = Stagehand::Client.new(
browserbase_api_key: "My Browserbase API Key",
browserbase_project_id: "My Browserbase Project ID",
model_api_key: "My Model API Key"
)
response = stagehand.sessions.start(model_name: "openai/gpt-5.4-mini")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Stagehand\Client;
use Stagehand\Core\Exceptions\APIException;
$client = new Client(
browserbaseAPIKey: getenv('BROWSERBASE_API_KEY') ?: 'My Browserbase API Key',
browserbaseProjectID: getenv(
'BROWSERBASE_PROJECT_ID'
) ?: 'My Browserbase Project ID',
modelAPIKey: getenv('MODEL_API_KEY') ?: 'My Model API Key',
);
try {
$response = $client->sessions->start(
modelName: 'openai/gpt-5.4-mini',
actTimeoutMs: 0,
browser: [
'cdpURL' => 'ws://localhost:9222',
'launchOptions' => [
'acceptDownloads' => true,
'args' => ['string'],
'cdpHeaders' => ['foo' => 'string'],
'cdpURL' => 'cdpUrl',
'chromiumSandbox' => true,
'connectTimeoutMs' => 0,
'deviceScaleFactor' => 0,
'devtools' => true,
'downloadsPath' => 'downloadsPath',
'executablePath' => 'executablePath',
'hasTouch' => true,
'headless' => true,
'ignoreDefaultArgs' => true,
'ignoreHTTPSErrors' => true,
'locale' => 'locale',
'port' => 0,
'preserveUserDataDir' => true,
'proxy' => [
'server' => 'server',
'bypass' => 'bypass',
'password' => 'password',
'username' => 'username',
],
'userDataDir' => 'userDataDir',
'viewport' => ['height' => 0, 'width' => 0],
],
'type' => 'local',
],
browserbaseSessionCreateParams: [
'browserSettings' => [
'advancedStealth' => true,
'blockAds' => true,
'captchaImageSelector' => 'captchaImageSelector',
'captchaInputSelector' => 'captchaInputSelector',
'context' => ['id' => 'id', 'persist' => true],
'extensionID' => 'extensionId',
'fingerprint' => [
'browsers' => ['chrome'],
'devices' => ['desktop'],
'httpVersion' => '1',
'locales' => ['string'],
'operatingSystems' => ['android'],
'screen' => [
'maxHeight' => 0, 'maxWidth' => 0, 'minHeight' => 0, 'minWidth' => 0
],
],
'logSession' => true,
'os' => 'windows',
'recordSession' => true,
'solveCaptchas' => true,
'verified' => true,
'viewport' => ['height' => 0, 'width' => 0],
],
'extensionID' => 'extensionId',
'keepAlive' => true,
'projectID' => 'projectId',
'proxies' => true,
'region' => 'us-west-2',
'timeout' => 0,
'userMetadata' => ['foo' => 'bar'],
],
browserbaseSessionID: 'browserbaseSessionID',
domSettleTimeoutMs: 5000,
experimental: true,
selfHeal: true,
systemPrompt: 'systemPrompt',
verbose: 1,
waitForCaptchaSolves: true,
xStreamResponse: 'true',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}using System;
using Stagehand;
using Stagehand.Models.Sessions;
StagehandClient client = new();
SessionStartParams parameters = new() { ModelName = "openai/gpt-5.4-mini" };
var response = await client.Sessions.Start(parameters);
Console.WriteLine(response);curl --request POST \
--url https://api.stagehand.browserbase.com/v1/sessions/start \
--header 'Content-Type: application/json' \
--header 'x-bb-api-key: <api-key>' \
--header 'x-bb-project-id: <api-key>' \
--data '
{
"modelName": "openai/gpt-5.4-mini",
"domSettleTimeoutMs": 5000,
"verbose": 1,
"systemPrompt": "<string>",
"browserbaseSessionCreateParams": {
"projectId": "<string>",
"browserSettings": {
"advancedStealth": true,
"blockAds": true,
"captchaImageSelector": "<string>",
"captchaInputSelector": "<string>",
"extensionId": "<string>",
"fingerprint": {
"browsers": [],
"devices": [],
"locales": [
"<string>"
],
"operatingSystems": [],
"screen": {
"maxHeight": 123,
"maxWidth": 123,
"minHeight": 123,
"minWidth": 123
}
},
"logSession": true,
"recordSession": true,
"solveCaptchas": true,
"verified": true,
"viewport": {
"width": 123,
"height": 123
}
},
"extensionId": "<string>",
"keepAlive": true,
"proxies": true,
"timeout": 123,
"userMetadata": {}
},
"browser": {
"type": "local",
"cdpUrl": "ws://localhost:9222",
"launchOptions": {
"args": [
"<string>"
],
"executablePath": "<string>",
"port": 123,
"userDataDir": "<string>",
"preserveUserDataDir": true,
"headless": true,
"devtools": true,
"chromiumSandbox": true,
"ignoreDefaultArgs": true,
"locale": "<string>",
"deviceScaleFactor": 123,
"hasTouch": true,
"ignoreHTTPSErrors": true,
"cdpUrl": "<string>",
"cdpHeaders": {},
"connectTimeoutMs": 123,
"downloadsPath": "<string>",
"acceptDownloads": true
}
},
"selfHeal": true,
"browserbaseSessionID": "<string>",
"experimental": true,
"waitForCaptchaSolves": true,
"actTimeoutMs": 123
}
'{
"success": true,
"data": {
"sessionId": "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
"available": true,
"cdpUrl": "wss://connect.browserbase.com/?signingKey=abc123"
}
}
