stagehand

package module
v3.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

README

The AI Browser Automation Framework
Read the Docs

MIT License Discord Community

If you're looking for other languages, you can find them here

Vibe code Stagehand with Director Director

What is Stagehand?

Stagehand is a browser automation framework used to control web browsers with natural language and code. By combining the power of AI with the precision of code, Stagehand makes web automation flexible, maintainable, and actually reliable.

Why Stagehand?

Most existing browser automation tools either require you to write low-level code in a framework like Selenium, Playwright, or Puppeteer, or use high-level agents that can be unpredictable in production. By letting developers choose what to write in code vs. natural language (and bridging the gap between the two) Stagehand is the natural choice for browser automations in production.

  1. Choose when to write code vs. natural language: use AI when you want to navigate unfamiliar pages, and use code when you know exactly what you want to do.

  2. Go from AI-driven to repeatable workflows: Stagehand lets you preview AI actions before running them, and also helps you easily cache repeatable actions to save time and tokens.

  3. Write once, run forever: Stagehand's auto-caching combined with self-healing remembers previous actions, runs without LLM inference, and knows when to involve AI whenever the website changes and your automation breaks.

Stagehand Go API Library

Go Reference

Installation

import (
	"github.com/browserbase/stagehand-go/v3" // imported as stagehand
)

Or to pin the version:

go get -u 'github.com/browserbase/stagehand-go@v3.5.1'

Requirements

This library requires Go 1.22+.

Usage

The full API of this library can be found in api.md.

Stagehand can run in two modes:

  • Cloud mode: Uses Browserbase cloud browsers (recommended for production)
  • Local mode: Runs a local browser on your machine (great for development and testing)

Cloud Mode (Browserbase)

package main

import (
	"context"
	"fmt"

	"github.com/browserbase/stagehand-go/v3"
	"github.com/browserbase/stagehand-go/v3/option"
)

func main() {
	client := stagehand.NewClient(
		option.WithBrowserbaseAPIKey("My Browserbase API Key"),       // defaults to os.LookupEnv("BROWSERBASE_API_KEY")
		option.WithBrowserbaseProjectID("My Browserbase Project ID"), // defaults to os.LookupEnv("BROWSERBASE_PROJECT_ID")
		option.WithModelAPIKey("My Model API Key"),                   // defaults to os.LookupEnv("MODEL_API_KEY")
	)

	// Start a new browser session (uses Browserbase cloud by default)
	startResponse, err := client.Sessions.Start(context.TODO(), stagehand.SessionStartParams{
		ModelName: "openai/gpt-5-nano",
	})
	if err != nil {
		panic(err.Error())
	}
	sessionID := startResponse.Data.SessionID

	// Navigate, act, extract, etc.
	client.Sessions.Navigate(context.TODO(), sessionID, stagehand.SessionNavigateParams{
		URL: "https://example.com",
	})

	// End the session
	client.Sessions.End(context.TODO(), sessionID, stagehand.SessionEndParams{})
}

Local Mode

Local mode runs the browser on your machine. This is useful for development and testing without needing Browserbase credentials.

package main

import (
	"context"
	"fmt"

	"github.com/browserbase/stagehand-go/v3"
	"github.com/browserbase/stagehand-go/v3/option"
)

func main() {
	// Create a client in local mode
	client := stagehand.NewClient(option.WithServer("local"))
	defer client.Close()

	ctx := context.Background()

	// Start a session with local browser
	startResp, err := client.Sessions.Start(ctx, stagehand.SessionStartParams{
		ModelName: "openai/gpt-5-nano",
		Browser: stagehand.SessionStartParamsBrowser{
			Type: "local",
			LaunchOptions: stagehand.SessionStartParamsBrowserLaunchOptions{
				Headless: stagehand.Bool(true),
			},
		},
	})
	if err != nil {
		panic(err.Error())
	}
	sessionID := startResp.Data.SessionID

	// Navigate, act, extract - same API as cloud mode
	client.Sessions.Navigate(ctx, sessionID, stagehand.SessionNavigateParams{
		URL: "https://example.com",
	})

	extractResp, _ := client.Sessions.Extract(ctx, sessionID, stagehand.SessionExtractParams{
		Instruction: stagehand.String("extract the main heading"),
		Schema: map[string]any{
			"type": "object",
			"properties": map[string]any{
				"title": map[string]any{"type": "string"},
			},
		},
	})
	fmt.Printf("Extracted: %+v\n", extractResp.Data.Result)

	// End the session
	client.Sessions.End(ctx, sessionID, stagehand.SessionEndParams{})
}

Full Example (Cloud Mode)

This example demonstrates the complete workflow of using Stagehand. A runnable version is available at examples/basic/main.go.

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/browserbase/stagehand-go/v3"
)

func main() {
	// Create a new Stagehand client using environment variables
	// Configures using BROWSERBASE_API_KEY, BROWSERBASE_PROJECT_ID, and MODEL_API_KEY
	client := stagehand.NewClient()

	// Start a new browser session
	startResponse, err := client.Sessions.Start(context.TODO(), stagehand.SessionStartParams{
		ModelName: "openai/gpt-5-nano",
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("Session started: %s\n", startResponse.Data.SessionID)

	sessionID := startResponse.Data.SessionID

	// Navigate to Hacker News
	_, err = client.Sessions.Navigate(
		context.TODO(),
		sessionID,
		stagehand.SessionNavigateParams{
			URL: "https://news.ycombinator.com",
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Println("Navigated to Hacker News")

	// Use Observe to find possible actions on the page
	observeResponse, err := client.Sessions.Observe(
		context.TODO(),
		sessionID,
		stagehand.SessionObserveParams{
			Instruction: stagehand.String("find the link to view comments for the top post"),
		},
	)
	if err != nil {
		panic(err.Error())
	}

	actions := observeResponse.Data.Result
	fmt.Printf("Found %d possible actions\n", len(actions))

	if len(actions) == 0 {
		fmt.Println("No actions found")
		return
	}

	// Take the first action returned by Observe
	action := actions[0]
	fmt.Printf("Acting on: %s\n", action.Description)

	// Pass the structured action to Act
	actResponse, err := client.Sessions.Act(
		context.TODO(),
		sessionID,
		stagehand.SessionActParams{
			Input: stagehand.SessionActParamsInputUnion{
				OfAction: &stagehand.ActionParam{
					Description: action.Description,
					Selector:    action.Selector,
					Method:      stagehand.String(action.Method),
					Arguments:   action.Arguments,
				},
			},
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("Act completed: %s\n", actResponse.Data.Result.Message)

	// Extract structured data from the page using a JSON schema
	// We're now on the comments page, so extract the top comment text
	extractResponse, err := client.Sessions.Extract(
		context.TODO(),
		sessionID,
		stagehand.SessionExtractParams{
			Instruction: stagehand.String("extract the text of the top comment on this page"),
			Schema: map[string]any{
				"type": "object",
				"properties": map[string]any{
					"commentText": map[string]any{
						"type":        "string",
						"description": "The text content of the top comment",
					},
					"author": map[string]any{
						"type":        "string",
						"description": "The username of the comment author",
					},
				},
				"required": []string{"commentText"},
			},
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("Extracted data: %+v\n", extractResponse.Data.Result)

	// Get the author from the extracted data
	extractedData := extractResponse.Data.Result.(map[string]any)
	author := extractedData["author"].(string)
	fmt.Printf("Looking up profile for author: %s\n", author)

	// Use the Agent to find the author's profile
	// Execute runs an autonomous agent that can navigate and interact with pages
	executeResponse, err := client.Sessions.Execute(
		context.TODO(),
		sessionID,
		stagehand.SessionExecuteParams{
			ExecuteOptions: stagehand.SessionExecuteParamsExecuteOptions{
				Instruction: fmt.Sprintf(
					"Find any personal website, GitHub, LinkedIn, or other best profile URL for the Hacker News user '%s'. "+
						"Click on their username to go to their profile page and look for any links they have shared. "+
						"Use Google Search with their username or other details from their profile if you dont find any direct links.",
					author,
				),
				MaxSteps: stagehand.Float(15),
			},
			AgentConfig: stagehand.SessionExecuteParamsAgentConfig{
				Model: stagehand.SessionExecuteParamsAgentConfigModelUnion{
					OfModelConfig: &stagehand.ModelConfigParam{
						ModelName: "openai/gpt-5-nano",
						APIKey:    stagehand.String(os.Getenv("MODEL_API_KEY")),
					},
				},
				Cua: stagehand.Bool(false),
			},
		},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("Agent completed: %s\n", executeResponse.Data.Result.Message)
	fmt.Printf("Agent success: %t\n", executeResponse.Data.Result.Success)
	fmt.Printf("Agent actions taken: %d\n", len(executeResponse.Data.Result.Actions))

	// End the session to clean up resources
	_, err = client.Sessions.End(
		context.TODO(),
		sessionID,
		stagehand.SessionEndParams{},
	)
	if err != nil {
		panic(err.Error())
	}
	fmt.Println("Session ended")
}

Running the Examples

Several complete working examples are available:

Cloud examples (Browserbase):

Example Description
examples/basic/ Cloud mode using Browserbase
examples/chromedp_browserbase_example/ Combining chromedp with Browserbase
examples/chromedp_multiregion_example/ Running with a Browserbase browser in a specific region

Local examples:

Example Description
examples/local/ Local mode using a local browser
examples/chromedp_local_example/ Combining chromedp with local browser
Cloud Examples (Browserbase)

Set up environment variables:

export BROWSERBASE_API_KEY=your_browserbase_api_key
export BROWSERBASE_PROJECT_ID=your_browserbase_project_id
export MODEL_API_KEY=your_openai_api_key

You can get your Browserbase API key and project ID from the Browserbase dashboard.

Run the examples:

go run examples/basic/main.go
go run examples/chromedp_browserbase_example/main.go
go run examples/chromedp_multiregion_example/main.go
Local Examples

Set up environment variables (only MODEL_API_KEY is required for local mode):

export MODEL_API_KEY=your_openai_api_key

Run the examples:

go run examples/local/main.go
go run examples/chromedp_local_example/main.go

The chromedp examples demonstrate how to combine low-level browser control (via chromedp) with AI-powered actions (via Stagehand) on the same browser session.

Request fields

The stagehand library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `json:"...,required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, stagehand.String(string), stagehand.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := stagehand.ExampleParams{
	ID:   "id_xxx",                // required property
	Name: stagehand.String("..."), // optional property

	Point: stagehand.Point{
		X: 0,                // required field will serialize as 0
		Y: stagehand.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: stagehand.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[stagehand.FooParams](12)

Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of its variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat *Cat `json:",omitzero,inline`
	OfDog *Dog `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}

Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()

Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}

RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := stagehand.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Sessions.Start(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

Errors

When the API returns a non-success status code, we return an error with type *stagehand.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Sessions.Start(context.TODO(), stagehand.SessionStartParams{
	ModelName: "openai/gpt-5-nano",
})
if err != nil {
	var apierr *stagehand.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/v1/sessions/start": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Sessions.Start(
	ctx,
	stagehand.SessionStartParams{
		ModelName: "openai/gpt-5-nano",
	},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)

File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper stagehand.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := stagehand.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Sessions.Start(
	context.TODO(),
	stagehand.SessionStartParams{
		ModelName: "openai/gpt-5-nano",
	},
	option.WithMaxRetries(5),
)

Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
response, err := client.Sessions.Start(
	context.TODO(),
	stagehand.SessionStartParams{
		ModelName: "openai/gpt-5-nano",
	},
	option.WithResponseInto(&response),
)
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", response)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)

Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: stagehand.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := stagehand.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Overview

Custom code. Not generated by Stainless.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (BROWSERBASE_API_KEY, MODEL_API_KEY, BROWSERBASE_PROJECT_ID, STAGEHAND_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type ActionParam

type ActionParam struct {
	// Human-readable description of the action
	Description string `json:"description,required"`
	// CSS selector or XPath for the element
	Selector string `json:"selector,required"`
	// Backend node ID for the element
	BackendNodeID param.Opt[float64] `json:"backendNodeId,omitzero"`
	// The method to execute (click, fill, etc.)
	Method param.Opt[string] `json:"method,omitzero"`
	// Arguments to pass to the method
	Arguments []string `json:"arguments,omitzero"`
	// contains filtered or unexported fields
}

Action object returned by observe and used by act

The properties Description, Selector are required.

func (ActionParam) MarshalJSON

func (r ActionParam) MarshalJSON() (data []byte, err error)

func (*ActionParam) UnmarshalJSON

func (r *ActionParam) UnmarshalJSON(data []byte) error

type Client

type Client struct {
	Options  []option.RequestOption
	Sessions SessionService
}

Client creates a struct with services and top level methods that help with interacting with the stagehand API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (BROWSERBASE_API_KEY, MODEL_API_KEY, BROWSERBASE_PROJECT_ID, STAGEHAND_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (Client) Close added in v3.1.0

func (c Client) Close() error

Close shuts down any local mode processes associated with this client.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned [url.Values] will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type Error

type Error = apierror.Error

type ModelConfigParam added in v3.1.0

type ModelConfigParam struct {
	// Model name string with provider prefix (e.g., 'openai/gpt-5-nano')
	ModelName string `json:"modelName,required"`
	// API key for the model provider
	APIKey param.Opt[string] `json:"apiKey,omitzero"`
	// Base URL for the model provider
	BaseURL param.Opt[string] `json:"baseURL,omitzero" format:"uri"`
	// AI provider for the model (or provide a baseURL endpoint instead)
	//
	// Any of "openai", "anthropic", "google", "microsoft".
	Provider ModelConfigProvider `json:"provider,omitzero"`
	// contains filtered or unexported fields
}

The property ModelName is required.

func (ModelConfigParam) MarshalJSON added in v3.1.0

func (r ModelConfigParam) MarshalJSON() (data []byte, err error)

func (*ModelConfigParam) UnmarshalJSON added in v3.1.0

func (r *ModelConfigParam) UnmarshalJSON(data []byte) error

type ModelConfigProvider added in v3.1.0

type ModelConfigProvider string

AI provider for the model (or provide a baseURL endpoint instead)

const (
	ModelConfigProviderOpenAI    ModelConfigProvider = "openai"
	ModelConfigProviderAnthropic ModelConfigProvider = "anthropic"
	ModelConfigProviderGoogle    ModelConfigProvider = "google"
	ModelConfigProviderMicrosoft ModelConfigProvider = "microsoft"
)

type SessionActParams

type SessionActParams struct {
	// Natural language instruction or Action object
	Input SessionActParamsInputUnion `json:"input,omitzero,required"`
	// Target frame ID for the action
	FrameID param.Opt[string]       `json:"frameId,omitzero"`
	Options SessionActParamsOptions `json:"options,omitzero"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionActParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (SessionActParams) MarshalJSON

func (r SessionActParams) MarshalJSON() (data []byte, err error)

func (*SessionActParams) UnmarshalJSON

func (r *SessionActParams) UnmarshalJSON(data []byte) error

type SessionActParamsInputUnion

type SessionActParamsInputUnion struct {
	OfString param.Opt[string] `json:",omitzero,inline"`
	OfAction *ActionParam      `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SessionActParamsInputUnion) MarshalJSON

func (u SessionActParamsInputUnion) MarshalJSON() ([]byte, error)

func (*SessionActParamsInputUnion) UnmarshalJSON

func (u *SessionActParamsInputUnion) UnmarshalJSON(data []byte) error

type SessionActParamsOptions

type SessionActParamsOptions struct {
	// Timeout in ms for the action
	Timeout param.Opt[float64] `json:"timeout,omitzero"`
	// Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
	Model SessionActParamsOptionsModelUnion `json:"model,omitzero"`
	// Variables to substitute in the action instruction
	Variables map[string]string `json:"variables,omitzero"`
	// contains filtered or unexported fields
}

func (SessionActParamsOptions) MarshalJSON

func (r SessionActParamsOptions) MarshalJSON() (data []byte, err error)

func (*SessionActParamsOptions) UnmarshalJSON

func (r *SessionActParamsOptions) UnmarshalJSON(data []byte) error

type SessionActParamsOptionsModelUnion added in v3.4.0

type SessionActParamsOptionsModelUnion struct {
	OfModelConfig *ModelConfigParam `json:",omitzero,inline"`
	OfString      param.Opt[string] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SessionActParamsOptionsModelUnion) MarshalJSON added in v3.4.0

func (u SessionActParamsOptionsModelUnion) MarshalJSON() ([]byte, error)

func (*SessionActParamsOptionsModelUnion) UnmarshalJSON added in v3.4.0

func (u *SessionActParamsOptionsModelUnion) UnmarshalJSON(data []byte) error

type SessionActParamsXStreamResponse

type SessionActParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionActParamsXStreamResponseTrue  SessionActParamsXStreamResponse = "true"
	SessionActParamsXStreamResponseFalse SessionActParamsXStreamResponse = "false"
)

type SessionActResponse

type SessionActResponse struct {
	Data SessionActResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionActResponse) RawJSON

func (r SessionActResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionActResponse) UnmarshalJSON

func (r *SessionActResponse) UnmarshalJSON(data []byte) error

type SessionActResponseData

type SessionActResponseData struct {
	Result SessionActResponseDataResult `json:"result,required"`
	// Action ID for tracking
	ActionID string `json:"actionId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ActionID    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionActResponseData) RawJSON

func (r SessionActResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionActResponseData) UnmarshalJSON

func (r *SessionActResponseData) UnmarshalJSON(data []byte) error

type SessionActResponseDataResult

type SessionActResponseDataResult struct {
	// Description of the action that was performed
	ActionDescription string `json:"actionDescription,required"`
	// List of actions that were executed
	Actions []SessionActResponseDataResultAction `json:"actions,required"`
	// Human-readable result message
	Message string `json:"message,required"`
	// Whether the action completed successfully
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ActionDescription respjson.Field
		Actions           respjson.Field
		Message           respjson.Field
		Success           respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionActResponseDataResult) RawJSON

Returns the unmodified JSON received from the API

func (*SessionActResponseDataResult) UnmarshalJSON

func (r *SessionActResponseDataResult) UnmarshalJSON(data []byte) error

type SessionActResponseDataResultAction

type SessionActResponseDataResultAction struct {
	// Human-readable description of the action
	Description string `json:"description,required"`
	// CSS selector or XPath for the element
	Selector string `json:"selector,required"`
	// Arguments to pass to the method
	Arguments []string `json:"arguments"`
	// Backend node ID for the element
	BackendNodeID float64 `json:"backendNodeId"`
	// The method to execute (click, fill, etc.)
	Method string `json:"method"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description   respjson.Field
		Selector      respjson.Field
		Arguments     respjson.Field
		BackendNodeID respjson.Field
		Method        respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Action object returned by observe and used by act

func (SessionActResponseDataResultAction) RawJSON

Returns the unmodified JSON received from the API

func (*SessionActResponseDataResultAction) UnmarshalJSON

func (r *SessionActResponseDataResultAction) UnmarshalJSON(data []byte) error

type SessionEndParams

type SessionEndParams struct {
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionEndParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

type SessionEndParamsXStreamResponse

type SessionEndParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionEndParamsXStreamResponseTrue  SessionEndParamsXStreamResponse = "true"
	SessionEndParamsXStreamResponseFalse SessionEndParamsXStreamResponse = "false"
)

type SessionEndResponse

type SessionEndResponse struct {
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionEndResponse) RawJSON

func (r SessionEndResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionEndResponse) UnmarshalJSON

func (r *SessionEndResponse) UnmarshalJSON(data []byte) error

type SessionExecuteParams

type SessionExecuteParams struct {
	AgentConfig    SessionExecuteParamsAgentConfig    `json:"agentConfig,omitzero,required"`
	ExecuteOptions SessionExecuteParamsExecuteOptions `json:"executeOptions,omitzero,required"`
	// Target frame ID for the agent
	FrameID param.Opt[string] `json:"frameId,omitzero"`
	// If true, the server captures a cache entry and returns it to the client
	ShouldCache param.Opt[bool] `json:"shouldCache,omitzero"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionExecuteParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (SessionExecuteParams) MarshalJSON

func (r SessionExecuteParams) MarshalJSON() (data []byte, err error)

func (*SessionExecuteParams) UnmarshalJSON

func (r *SessionExecuteParams) UnmarshalJSON(data []byte) error

type SessionExecuteParamsAgentConfig

type SessionExecuteParamsAgentConfig struct {
	// Enable Computer Use Agent mode
	Cua param.Opt[bool] `json:"cua,omitzero"`
	// Custom system prompt for the agent
	SystemPrompt param.Opt[string] `json:"systemPrompt,omitzero"`
	// Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
	Model SessionExecuteParamsAgentConfigModelUnion `json:"model,omitzero"`
	// AI provider for the agent (legacy, use model: openai/gpt-5-nano instead)
	//
	// Any of "openai", "anthropic", "google", "microsoft".
	Provider string `json:"provider,omitzero"`
	// contains filtered or unexported fields
}

func (SessionExecuteParamsAgentConfig) MarshalJSON

func (r SessionExecuteParamsAgentConfig) MarshalJSON() (data []byte, err error)

func (*SessionExecuteParamsAgentConfig) UnmarshalJSON

func (r *SessionExecuteParamsAgentConfig) UnmarshalJSON(data []byte) error

type SessionExecuteParamsAgentConfigModelUnion added in v3.4.0

type SessionExecuteParamsAgentConfigModelUnion struct {
	OfModelConfig *ModelConfigParam `json:",omitzero,inline"`
	OfString      param.Opt[string] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SessionExecuteParamsAgentConfigModelUnion) MarshalJSON added in v3.4.0

func (*SessionExecuteParamsAgentConfigModelUnion) UnmarshalJSON added in v3.4.0

func (u *SessionExecuteParamsAgentConfigModelUnion) UnmarshalJSON(data []byte) error

type SessionExecuteParamsExecuteOptions

type SessionExecuteParamsExecuteOptions struct {
	// Natural language instruction for the agent
	Instruction string `json:"instruction,required"`
	// Whether to visually highlight the cursor during execution
	HighlightCursor param.Opt[bool] `json:"highlightCursor,omitzero"`
	// Maximum number of steps the agent can take
	MaxSteps param.Opt[float64] `json:"maxSteps,omitzero"`
	// contains filtered or unexported fields
}

The property Instruction is required.

func (SessionExecuteParamsExecuteOptions) MarshalJSON

func (r SessionExecuteParamsExecuteOptions) MarshalJSON() (data []byte, err error)

func (*SessionExecuteParamsExecuteOptions) UnmarshalJSON

func (r *SessionExecuteParamsExecuteOptions) UnmarshalJSON(data []byte) error

type SessionExecuteParamsXStreamResponse

type SessionExecuteParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionExecuteParamsXStreamResponseTrue  SessionExecuteParamsXStreamResponse = "true"
	SessionExecuteParamsXStreamResponseFalse SessionExecuteParamsXStreamResponse = "false"
)

type SessionExecuteResponse

type SessionExecuteResponse struct {
	Data SessionExecuteResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponse) RawJSON

func (r SessionExecuteResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionExecuteResponse) UnmarshalJSON

func (r *SessionExecuteResponse) UnmarshalJSON(data []byte) error

type SessionExecuteResponseData

type SessionExecuteResponseData struct {
	Result     SessionExecuteResponseDataResult     `json:"result,required"`
	CacheEntry SessionExecuteResponseDataCacheEntry `json:"cacheEntry"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		CacheEntry  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponseData) RawJSON

func (r SessionExecuteResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionExecuteResponseData) UnmarshalJSON

func (r *SessionExecuteResponseData) UnmarshalJSON(data []byte) error

type SessionExecuteResponseDataCacheEntry added in v3.3.0

type SessionExecuteResponseDataCacheEntry struct {
	// Opaque cache identifier computed from instruction, URL, options, and config
	CacheKey string `json:"cacheKey,required"`
	// Serialized cache entry that can be written to disk
	Entry any `json:"entry,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CacheKey    respjson.Field
		Entry       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponseDataCacheEntry) RawJSON added in v3.3.0

Returns the unmodified JSON received from the API

func (*SessionExecuteResponseDataCacheEntry) UnmarshalJSON added in v3.3.0

func (r *SessionExecuteResponseDataCacheEntry) UnmarshalJSON(data []byte) error

type SessionExecuteResponseDataResult

type SessionExecuteResponseDataResult struct {
	Actions []SessionExecuteResponseDataResultAction `json:"actions,required"`
	// Whether the agent finished its task
	Completed bool `json:"completed,required"`
	// Summary of what the agent accomplished
	Message string `json:"message,required"`
	// Whether the agent completed successfully
	Success  bool                                  `json:"success,required"`
	Metadata map[string]any                        `json:"metadata"`
	Usage    SessionExecuteResponseDataResultUsage `json:"usage"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Actions     respjson.Field
		Completed   respjson.Field
		Message     respjson.Field
		Success     respjson.Field
		Metadata    respjson.Field
		Usage       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponseDataResult) RawJSON

Returns the unmodified JSON received from the API

func (*SessionExecuteResponseDataResult) UnmarshalJSON

func (r *SessionExecuteResponseDataResult) UnmarshalJSON(data []byte) error

type SessionExecuteResponseDataResultAction

type SessionExecuteResponseDataResultAction struct {
	// Type of action taken
	Type        string `json:"type,required"`
	Action      string `json:"action"`
	Instruction string `json:"instruction"`
	PageText    string `json:"pageText"`
	PageURL     string `json:"pageUrl"`
	// Agent's reasoning for taking this action
	Reasoning     string `json:"reasoning"`
	TaskCompleted bool   `json:"taskCompleted"`
	// Time taken for this action in ms
	TimeMs      float64        `json:"timeMs"`
	ExtraFields map[string]any `json:",extras"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Type          respjson.Field
		Action        respjson.Field
		Instruction   respjson.Field
		PageText      respjson.Field
		PageURL       respjson.Field
		Reasoning     respjson.Field
		TaskCompleted respjson.Field
		TimeMs        respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponseDataResultAction) RawJSON

Returns the unmodified JSON received from the API

func (*SessionExecuteResponseDataResultAction) UnmarshalJSON

func (r *SessionExecuteResponseDataResultAction) UnmarshalJSON(data []byte) error

type SessionExecuteResponseDataResultUsage

type SessionExecuteResponseDataResultUsage struct {
	InferenceTimeMs   float64 `json:"inference_time_ms,required"`
	InputTokens       float64 `json:"input_tokens,required"`
	OutputTokens      float64 `json:"output_tokens,required"`
	CachedInputTokens float64 `json:"cached_input_tokens"`
	ReasoningTokens   float64 `json:"reasoning_tokens"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		InferenceTimeMs   respjson.Field
		InputTokens       respjson.Field
		OutputTokens      respjson.Field
		CachedInputTokens respjson.Field
		ReasoningTokens   respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExecuteResponseDataResultUsage) RawJSON

Returns the unmodified JSON received from the API

func (*SessionExecuteResponseDataResultUsage) UnmarshalJSON

func (r *SessionExecuteResponseDataResultUsage) UnmarshalJSON(data []byte) error

type SessionExtractParams

type SessionExtractParams struct {
	// Target frame ID for the extraction
	FrameID param.Opt[string] `json:"frameId,omitzero"`
	// Natural language instruction for what to extract
	Instruction param.Opt[string]           `json:"instruction,omitzero"`
	Options     SessionExtractParamsOptions `json:"options,omitzero"`
	// JSON Schema defining the structure of data to extract
	Schema map[string]any `json:"schema,omitzero"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionExtractParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (SessionExtractParams) MarshalJSON

func (r SessionExtractParams) MarshalJSON() (data []byte, err error)

func (*SessionExtractParams) UnmarshalJSON

func (r *SessionExtractParams) UnmarshalJSON(data []byte) error

type SessionExtractParamsOptions

type SessionExtractParamsOptions struct {
	// CSS selector to scope extraction to a specific element
	Selector param.Opt[string] `json:"selector,omitzero"`
	// Timeout in ms for the extraction
	Timeout param.Opt[float64] `json:"timeout,omitzero"`
	// Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
	Model SessionExtractParamsOptionsModelUnion `json:"model,omitzero"`
	// contains filtered or unexported fields
}

func (SessionExtractParamsOptions) MarshalJSON

func (r SessionExtractParamsOptions) MarshalJSON() (data []byte, err error)

func (*SessionExtractParamsOptions) UnmarshalJSON

func (r *SessionExtractParamsOptions) UnmarshalJSON(data []byte) error

type SessionExtractParamsOptionsModelUnion added in v3.4.0

type SessionExtractParamsOptionsModelUnion struct {
	OfModelConfig *ModelConfigParam `json:",omitzero,inline"`
	OfString      param.Opt[string] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SessionExtractParamsOptionsModelUnion) MarshalJSON added in v3.4.0

func (u SessionExtractParamsOptionsModelUnion) MarshalJSON() ([]byte, error)

func (*SessionExtractParamsOptionsModelUnion) UnmarshalJSON added in v3.4.0

func (u *SessionExtractParamsOptionsModelUnion) UnmarshalJSON(data []byte) error

type SessionExtractParamsXStreamResponse

type SessionExtractParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionExtractParamsXStreamResponseTrue  SessionExtractParamsXStreamResponse = "true"
	SessionExtractParamsXStreamResponseFalse SessionExtractParamsXStreamResponse = "false"
)

type SessionExtractResponse

type SessionExtractResponse struct {
	Data SessionExtractResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExtractResponse) RawJSON

func (r SessionExtractResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionExtractResponse) UnmarshalJSON

func (r *SessionExtractResponse) UnmarshalJSON(data []byte) error

type SessionExtractResponseData

type SessionExtractResponseData struct {
	// Extracted data matching the requested schema
	Result any `json:"result,required"`
	// Action ID for tracking
	ActionID string `json:"actionId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ActionID    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionExtractResponseData) RawJSON

func (r SessionExtractResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionExtractResponseData) UnmarshalJSON

func (r *SessionExtractResponseData) UnmarshalJSON(data []byte) error

type SessionNavigateParams

type SessionNavigateParams struct {
	// URL to navigate to
	URL string `json:"url,required"`
	// Target frame ID for the navigation
	FrameID param.Opt[string] `json:"frameId,omitzero"`
	// Whether to stream the response via SSE
	StreamResponse param.Opt[bool]              `json:"streamResponse,omitzero"`
	Options        SessionNavigateParamsOptions `json:"options,omitzero"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionNavigateParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (SessionNavigateParams) MarshalJSON

func (r SessionNavigateParams) MarshalJSON() (data []byte, err error)

func (*SessionNavigateParams) UnmarshalJSON

func (r *SessionNavigateParams) UnmarshalJSON(data []byte) error

type SessionNavigateParamsOptions

type SessionNavigateParamsOptions struct {
	// Referer header to send with the request
	Referer param.Opt[string] `json:"referer,omitzero"`
	// Timeout in ms for the navigation
	Timeout param.Opt[float64] `json:"timeout,omitzero"`
	// When to consider navigation complete
	//
	// Any of "load", "domcontentloaded", "networkidle".
	WaitUntil string `json:"waitUntil,omitzero"`
	// contains filtered or unexported fields
}

func (SessionNavigateParamsOptions) MarshalJSON

func (r SessionNavigateParamsOptions) MarshalJSON() (data []byte, err error)

func (*SessionNavigateParamsOptions) UnmarshalJSON

func (r *SessionNavigateParamsOptions) UnmarshalJSON(data []byte) error

type SessionNavigateParamsXStreamResponse

type SessionNavigateParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionNavigateParamsXStreamResponseTrue  SessionNavigateParamsXStreamResponse = "true"
	SessionNavigateParamsXStreamResponseFalse SessionNavigateParamsXStreamResponse = "false"
)

type SessionNavigateResponse

type SessionNavigateResponse struct {
	Data SessionNavigateResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionNavigateResponse) RawJSON

func (r SessionNavigateResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionNavigateResponse) UnmarshalJSON

func (r *SessionNavigateResponse) UnmarshalJSON(data []byte) error

type SessionNavigateResponseData

type SessionNavigateResponseData struct {
	// Navigation response (Playwright Response object or null)
	Result any `json:"result,required"`
	// Action ID for tracking
	ActionID string `json:"actionId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ActionID    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionNavigateResponseData) RawJSON

func (r SessionNavigateResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionNavigateResponseData) UnmarshalJSON

func (r *SessionNavigateResponseData) UnmarshalJSON(data []byte) error

type SessionObserveParams

type SessionObserveParams struct {
	// Target frame ID for the observation
	FrameID param.Opt[string] `json:"frameId,omitzero"`
	// Natural language instruction for what actions to find
	Instruction param.Opt[string]           `json:"instruction,omitzero"`
	Options     SessionObserveParamsOptions `json:"options,omitzero"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionObserveParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (SessionObserveParams) MarshalJSON

func (r SessionObserveParams) MarshalJSON() (data []byte, err error)

func (*SessionObserveParams) UnmarshalJSON

func (r *SessionObserveParams) UnmarshalJSON(data []byte) error

type SessionObserveParamsOptions

type SessionObserveParamsOptions struct {
	// CSS selector to scope observation to a specific element
	Selector param.Opt[string] `json:"selector,omitzero"`
	// Timeout in ms for the observation
	Timeout param.Opt[float64] `json:"timeout,omitzero"`
	// Model configuration object or model name string (e.g., 'openai/gpt-5-nano')
	Model SessionObserveParamsOptionsModelUnion `json:"model,omitzero"`
	// contains filtered or unexported fields
}

func (SessionObserveParamsOptions) MarshalJSON

func (r SessionObserveParamsOptions) MarshalJSON() (data []byte, err error)

func (*SessionObserveParamsOptions) UnmarshalJSON

func (r *SessionObserveParamsOptions) UnmarshalJSON(data []byte) error

type SessionObserveParamsOptionsModelUnion added in v3.4.0

type SessionObserveParamsOptionsModelUnion struct {
	OfModelConfig *ModelConfigParam `json:",omitzero,inline"`
	OfString      param.Opt[string] `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SessionObserveParamsOptionsModelUnion) MarshalJSON added in v3.4.0

func (u SessionObserveParamsOptionsModelUnion) MarshalJSON() ([]byte, error)

func (*SessionObserveParamsOptionsModelUnion) UnmarshalJSON added in v3.4.0

func (u *SessionObserveParamsOptionsModelUnion) UnmarshalJSON(data []byte) error

type SessionObserveParamsXStreamResponse

type SessionObserveParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionObserveParamsXStreamResponseTrue  SessionObserveParamsXStreamResponse = "true"
	SessionObserveParamsXStreamResponseFalse SessionObserveParamsXStreamResponse = "false"
)

type SessionObserveResponse

type SessionObserveResponse struct {
	Data SessionObserveResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionObserveResponse) RawJSON

func (r SessionObserveResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionObserveResponse) UnmarshalJSON

func (r *SessionObserveResponse) UnmarshalJSON(data []byte) error

type SessionObserveResponseData

type SessionObserveResponseData struct {
	Result []SessionObserveResponseDataResult `json:"result,required"`
	// Action ID for tracking
	ActionID string `json:"actionId"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Result      respjson.Field
		ActionID    respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionObserveResponseData) RawJSON

func (r SessionObserveResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionObserveResponseData) UnmarshalJSON

func (r *SessionObserveResponseData) UnmarshalJSON(data []byte) error

type SessionObserveResponseDataResult

type SessionObserveResponseDataResult struct {
	// Human-readable description of the action
	Description string `json:"description,required"`
	// CSS selector or XPath for the element
	Selector string `json:"selector,required"`
	// Arguments to pass to the method
	Arguments []string `json:"arguments"`
	// Backend node ID for the element
	BackendNodeID float64 `json:"backendNodeId"`
	// The method to execute (click, fill, etc.)
	Method string `json:"method"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Description   respjson.Field
		Selector      respjson.Field
		Arguments     respjson.Field
		BackendNodeID respjson.Field
		Method        respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Action object returned by observe and used by act

func (SessionObserveResponseDataResult) RawJSON

Returns the unmodified JSON received from the API

func (*SessionObserveResponseDataResult) UnmarshalJSON

func (r *SessionObserveResponseDataResult) UnmarshalJSON(data []byte) error

type SessionReplayParams added in v3.5.0

type SessionReplayParams struct {
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionReplayParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

type SessionReplayParamsXStreamResponse added in v3.5.0

type SessionReplayParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionReplayParamsXStreamResponseTrue  SessionReplayParamsXStreamResponse = "true"
	SessionReplayParamsXStreamResponseFalse SessionReplayParamsXStreamResponse = "false"
)

type SessionReplayResponse added in v3.5.0

type SessionReplayResponse struct {
	Data SessionReplayResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionReplayResponse) RawJSON added in v3.5.0

func (r SessionReplayResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionReplayResponse) UnmarshalJSON added in v3.5.0

func (r *SessionReplayResponse) UnmarshalJSON(data []byte) error

type SessionReplayResponseData added in v3.5.0

type SessionReplayResponseData struct {
	Pages []SessionReplayResponseDataPage `json:"pages"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Pages       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionReplayResponseData) RawJSON added in v3.5.0

func (r SessionReplayResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionReplayResponseData) UnmarshalJSON added in v3.5.0

func (r *SessionReplayResponseData) UnmarshalJSON(data []byte) error

type SessionReplayResponseDataPage added in v3.5.0

type SessionReplayResponseDataPage struct {
	Actions []SessionReplayResponseDataPageAction `json:"actions"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Actions     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionReplayResponseDataPage) RawJSON added in v3.5.0

Returns the unmodified JSON received from the API

func (*SessionReplayResponseDataPage) UnmarshalJSON added in v3.5.0

func (r *SessionReplayResponseDataPage) UnmarshalJSON(data []byte) error

type SessionReplayResponseDataPageAction added in v3.5.0

type SessionReplayResponseDataPageAction struct {
	Method     string                                        `json:"method"`
	TokenUsage SessionReplayResponseDataPageActionTokenUsage `json:"tokenUsage"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Method      respjson.Field
		TokenUsage  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionReplayResponseDataPageAction) RawJSON added in v3.5.0

Returns the unmodified JSON received from the API

func (*SessionReplayResponseDataPageAction) UnmarshalJSON added in v3.5.0

func (r *SessionReplayResponseDataPageAction) UnmarshalJSON(data []byte) error

type SessionReplayResponseDataPageActionTokenUsage added in v3.5.0

type SessionReplayResponseDataPageActionTokenUsage struct {
	CachedInputTokens float64 `json:"cachedInputTokens"`
	InputTokens       float64 `json:"inputTokens"`
	OutputTokens      float64 `json:"outputTokens"`
	ReasoningTokens   float64 `json:"reasoningTokens"`
	TimeMs            float64 `json:"timeMs"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		CachedInputTokens respjson.Field
		InputTokens       respjson.Field
		OutputTokens      respjson.Field
		ReasoningTokens   respjson.Field
		TimeMs            respjson.Field
		ExtraFields       map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionReplayResponseDataPageActionTokenUsage) RawJSON added in v3.5.0

Returns the unmodified JSON received from the API

func (*SessionReplayResponseDataPageActionTokenUsage) UnmarshalJSON added in v3.5.0

func (r *SessionReplayResponseDataPageActionTokenUsage) UnmarshalJSON(data []byte) error

type SessionService

type SessionService struct {
	Options []option.RequestOption
}

SessionService contains methods and other services that help with interacting with the stagehand API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewSessionService method instead.

func NewSessionService

func NewSessionService(opts ...option.RequestOption) (r SessionService)

NewSessionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*SessionService) Act

func (r *SessionService) Act(ctx context.Context, id string, params SessionActParams, opts ...option.RequestOption) (res *SessionActResponse, err error)

Executes a browser action using natural language instructions or a predefined Action object.

func (*SessionService) ActStreaming

func (r *SessionService) ActStreaming(ctx context.Context, id string, params SessionActParams, opts ...option.RequestOption) (stream *ssestream.Stream[StreamEvent])

Executes a browser action using natural language instructions or a predefined Action object.

func (*SessionService) End

Terminates the browser session and releases all associated resources.

func (*SessionService) Execute

Runs an autonomous AI agent that can perform complex multi-step browser tasks.

func (*SessionService) ExecuteStreaming

func (r *SessionService) ExecuteStreaming(ctx context.Context, id string, params SessionExecuteParams, opts ...option.RequestOption) (stream *ssestream.Stream[StreamEvent])

Runs an autonomous AI agent that can perform complex multi-step browser tasks.

func (*SessionService) Extract

Extracts structured data from the current page using AI-powered analysis.

func (*SessionService) ExtractStreaming

func (r *SessionService) ExtractStreaming(ctx context.Context, id string, params SessionExtractParams, opts ...option.RequestOption) (stream *ssestream.Stream[StreamEvent])

Extracts structured data from the current page using AI-powered analysis.

func (*SessionService) Navigate

Navigates the browser to the specified URL.

func (*SessionService) Observe

Identifies and returns available actions on the current page that match the given instruction.

func (*SessionService) ObserveStreaming

func (r *SessionService) ObserveStreaming(ctx context.Context, id string, params SessionObserveParams, opts ...option.RequestOption) (stream *ssestream.Stream[StreamEvent])

Identifies and returns available actions on the current page that match the given instruction.

func (*SessionService) Replay added in v3.5.0

Retrieves replay metrics for a session.

func (*SessionService) Start

Creates a new browser session with the specified configuration. Returns a session ID used for all subsequent operations.

type SessionStartParams

type SessionStartParams struct {
	// Model name to use for AI operations
	ModelName string `json:"modelName,required"`
	// Timeout in ms for act operations (deprecated, v2 only)
	ActTimeoutMs param.Opt[float64] `json:"actTimeoutMs,omitzero"`
	// Existing Browserbase session ID to resume
	BrowserbaseSessionID param.Opt[string] `json:"browserbaseSessionID,omitzero"`
	// Timeout in ms to wait for DOM to settle
	DomSettleTimeoutMs param.Opt[float64] `json:"domSettleTimeoutMs,omitzero"`
	Experimental       param.Opt[bool]    `json:"experimental,omitzero"`
	// Enable self-healing for failed actions
	SelfHeal param.Opt[bool] `json:"selfHeal,omitzero"`
	// Custom system prompt for AI operations
	SystemPrompt param.Opt[string] `json:"systemPrompt,omitzero"`
	// Wait for captcha solves (deprecated, v2 only)
	WaitForCaptchaSolves           param.Opt[bool]                                  `json:"waitForCaptchaSolves,omitzero"`
	Browser                        SessionStartParamsBrowser                        `json:"browser,omitzero"`
	BrowserbaseSessionCreateParams SessionStartParamsBrowserbaseSessionCreateParams `json:"browserbaseSessionCreateParams,omitzero"`
	// Logging verbosity level (0=quiet, 1=normal, 2=debug)
	//
	// Any of 0, 1, 2.
	Verbose float64 `json:"verbose,omitzero"`
	// Whether to stream the response via SSE
	//
	// Any of "true", "false".
	XStreamResponse SessionStartParamsXStreamResponse `header:"x-stream-response,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (SessionStartParams) MarshalJSON

func (r SessionStartParams) MarshalJSON() (data []byte, err error)

func (*SessionStartParams) UnmarshalJSON

func (r *SessionStartParams) UnmarshalJSON(data []byte) error

type SessionStartParamsBrowser

type SessionStartParamsBrowser struct {
	// Chrome DevTools Protocol URL for connecting to existing browser
	CdpURL        param.Opt[string]                      `json:"cdpUrl,omitzero"`
	LaunchOptions SessionStartParamsBrowserLaunchOptions `json:"launchOptions,omitzero"`
	// Browser type to use
	//
	// Any of "local", "browserbase".
	Type string `json:"type,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowser) MarshalJSON

func (r SessionStartParamsBrowser) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowser) UnmarshalJSON

func (r *SessionStartParamsBrowser) UnmarshalJSON(data []byte) error

type SessionStartParamsBrowserLaunchOptions

type SessionStartParamsBrowserLaunchOptions struct {
	AcceptDownloads     param.Opt[bool]                                              `json:"acceptDownloads,omitzero"`
	CdpURL              param.Opt[string]                                            `json:"cdpUrl,omitzero"`
	ChromiumSandbox     param.Opt[bool]                                              `json:"chromiumSandbox,omitzero"`
	ConnectTimeoutMs    param.Opt[float64]                                           `json:"connectTimeoutMs,omitzero"`
	DeviceScaleFactor   param.Opt[float64]                                           `json:"deviceScaleFactor,omitzero"`
	Devtools            param.Opt[bool]                                              `json:"devtools,omitzero"`
	DownloadsPath       param.Opt[string]                                            `json:"downloadsPath,omitzero"`
	ExecutablePath      param.Opt[string]                                            `json:"executablePath,omitzero"`
	HasTouch            param.Opt[bool]                                              `json:"hasTouch,omitzero"`
	Headless            param.Opt[bool]                                              `json:"headless,omitzero"`
	IgnoreHTTPSErrors   param.Opt[bool]                                              `json:"ignoreHTTPSErrors,omitzero"`
	Locale              param.Opt[string]                                            `json:"locale,omitzero"`
	Port                param.Opt[float64]                                           `json:"port,omitzero"`
	PreserveUserDataDir param.Opt[bool]                                              `json:"preserveUserDataDir,omitzero"`
	UserDataDir         param.Opt[string]                                            `json:"userDataDir,omitzero"`
	Args                []string                                                     `json:"args,omitzero"`
	IgnoreDefaultArgs   SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion `json:"ignoreDefaultArgs,omitzero"`
	Proxy               SessionStartParamsBrowserLaunchOptionsProxy                  `json:"proxy,omitzero"`
	Viewport            SessionStartParamsBrowserLaunchOptionsViewport               `json:"viewport,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserLaunchOptions) MarshalJSON

func (r SessionStartParamsBrowserLaunchOptions) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowserLaunchOptions) UnmarshalJSON

func (r *SessionStartParamsBrowserLaunchOptions) UnmarshalJSON(data []byte) error

type SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion

type SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion struct {
	OfBool        param.Opt[bool] `json:",omitzero,inline"`
	OfStringArray []string        `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion) MarshalJSON

func (*SessionStartParamsBrowserLaunchOptionsIgnoreDefaultArgsUnion) UnmarshalJSON

type SessionStartParamsBrowserLaunchOptionsProxy

type SessionStartParamsBrowserLaunchOptionsProxy struct {
	Server   string            `json:"server,required"`
	Bypass   param.Opt[string] `json:"bypass,omitzero"`
	Password param.Opt[string] `json:"password,omitzero"`
	Username param.Opt[string] `json:"username,omitzero"`
	// contains filtered or unexported fields
}

The property Server is required.

func (SessionStartParamsBrowserLaunchOptionsProxy) MarshalJSON

func (r SessionStartParamsBrowserLaunchOptionsProxy) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowserLaunchOptionsProxy) UnmarshalJSON

func (r *SessionStartParamsBrowserLaunchOptionsProxy) UnmarshalJSON(data []byte) error

type SessionStartParamsBrowserLaunchOptionsViewport

type SessionStartParamsBrowserLaunchOptionsViewport struct {
	Height float64 `json:"height,required"`
	Width  float64 `json:"width,required"`
	// contains filtered or unexported fields
}

The properties Height, Width are required.

func (SessionStartParamsBrowserLaunchOptionsViewport) MarshalJSON

func (r SessionStartParamsBrowserLaunchOptionsViewport) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowserLaunchOptionsViewport) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParams

type SessionStartParamsBrowserbaseSessionCreateParams struct {
	ExtensionID     param.Opt[string]                                               `json:"extensionId,omitzero"`
	KeepAlive       param.Opt[bool]                                                 `json:"keepAlive,omitzero"`
	ProjectID       param.Opt[string]                                               `json:"projectId,omitzero"`
	Timeout         param.Opt[float64]                                              `json:"timeout,omitzero"`
	BrowserSettings SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings `json:"browserSettings,omitzero"`
	Proxies         SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion    `json:"proxies,omitzero"`
	// Any of "us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1".
	Region       string         `json:"region,omitzero"`
	UserMetadata map[string]any `json:"userMetadata,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParams) MarshalJSON

func (r SessionStartParamsBrowserbaseSessionCreateParams) MarshalJSON() (data []byte, err error)

func (*SessionStartParamsBrowserbaseSessionCreateParams) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings struct {
	AdvancedStealth param.Opt[bool]                                                            `json:"advancedStealth,omitzero"`
	BlockAds        param.Opt[bool]                                                            `json:"blockAds,omitzero"`
	ExtensionID     param.Opt[string]                                                          `json:"extensionId,omitzero"`
	LogSession      param.Opt[bool]                                                            `json:"logSession,omitzero"`
	RecordSession   param.Opt[bool]                                                            `json:"recordSession,omitzero"`
	SolveCaptchas   param.Opt[bool]                                                            `json:"solveCaptchas,omitzero"`
	Context         SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext     `json:"context,omitzero"`
	Fingerprint     SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint `json:"fingerprint,omitzero"`
	Viewport        SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport    `json:"viewport,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettings) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext struct {
	ID      string          `json:"id,required"`
	Persist param.Opt[bool] `json:"persist,omitzero"`
	// contains filtered or unexported fields
}

The property ID is required.

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsContext) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint struct {
	// Any of "chrome", "edge", "firefox", "safari".
	Browsers []string `json:"browsers,omitzero"`
	// Any of "desktop", "mobile".
	Devices []string `json:"devices,omitzero"`
	// Any of "1", "2".
	HTTPVersion string   `json:"httpVersion,omitzero"`
	Locales     []string `json:"locales,omitzero"`
	// Any of "android", "ios", "linux", "macos", "windows".
	OperatingSystems []string                                                                         `json:"operatingSystems,omitzero"`
	Screen           SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen `json:"screen,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprint) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen struct {
	MaxHeight param.Opt[float64] `json:"maxHeight,omitzero"`
	MaxWidth  param.Opt[float64] `json:"maxWidth,omitzero"`
	MinHeight param.Opt[float64] `json:"minHeight,omitzero"`
	MinWidth  param.Opt[float64] `json:"minWidth,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsFingerprintScreen) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport

type SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport struct {
	Height param.Opt[float64] `json:"height,omitzero"`
	Width  param.Opt[float64] `json:"width,omitzero"`
	// contains filtered or unexported fields
}

func (SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsBrowserSettingsViewport) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase struct {
	DomainPattern param.Opt[string]                                                                                `json:"domainPattern,omitzero"`
	Geolocation   SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation `json:"geolocation,omitzero"`
	// This field can be elided, and will marshal its zero value as "browserbase".
	Type constant.Browserbase `json:"type,required"`
	// contains filtered or unexported fields
}

The property Type is required.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation struct {
	Country string            `json:"country,required"`
	City    param.Opt[string] `json:"city,omitzero"`
	State   param.Opt[string] `json:"state,omitzero"`
	// contains filtered or unexported fields
}

The property Country is required.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbaseGeolocation) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal struct {
	Server        string            `json:"server,required"`
	DomainPattern param.Opt[string] `json:"domainPattern,omitzero"`
	Password      param.Opt[string] `json:"password,omitzero"`
	Username      param.Opt[string] `json:"username,omitzero"`
	// This field can be elided, and will marshal its zero value as "external".
	Type constant.External `json:"type,required"`
	// contains filtered or unexported fields
}

The properties Server, Type are required.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion struct {
	OfBrowserbase *SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemBrowserbase `json:",omitzero,inline"`
	OfExternal    *SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemExternal    `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetDomainPattern

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetGeolocation

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetPassword

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetServer

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetType

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) GetUsername

Returns a pointer to the underlying variant's property, if present.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion) UnmarshalJSON

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion

type SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion struct {
	OfBool            param.Opt[bool]                                                                   `json:",omitzero,inline"`
	OfProxyConfigList []SessionStartParamsBrowserbaseSessionCreateParamsProxiesProxyConfigListItemUnion `json:",omitzero,inline"`
	// contains filtered or unexported fields
}

Only one field can be non-zero.

Use param.IsOmitted to confirm if a field is set.

func (SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion) MarshalJSON

func (*SessionStartParamsBrowserbaseSessionCreateParamsProxiesUnion) UnmarshalJSON

type SessionStartParamsXStreamResponse

type SessionStartParamsXStreamResponse string

Whether to stream the response via SSE

const (
	SessionStartParamsXStreamResponseTrue  SessionStartParamsXStreamResponse = "true"
	SessionStartParamsXStreamResponseFalse SessionStartParamsXStreamResponse = "false"
)

type SessionStartResponse

type SessionStartResponse struct {
	Data SessionStartResponseData `json:"data,required"`
	// Indicates whether the request was successful
	Success bool `json:"success,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Success     respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionStartResponse) RawJSON

func (r SessionStartResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionStartResponse) UnmarshalJSON

func (r *SessionStartResponse) UnmarshalJSON(data []byte) error

type SessionStartResponseData

type SessionStartResponseData struct {
	Available bool `json:"available,required"`
	// Unique Browserbase session identifier
	SessionID string `json:"sessionId,required"`
	// CDP WebSocket URL for connecting to the Browserbase cloud browser (present when
	// available)
	CdpURL string `json:"cdpUrl,nullable"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Available   respjson.Field
		SessionID   respjson.Field
		CdpURL      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (SessionStartResponseData) RawJSON

func (r SessionStartResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*SessionStartResponseData) UnmarshalJSON

func (r *SessionStartResponseData) UnmarshalJSON(data []byte) error

type StreamEvent

type StreamEvent struct {
	// Unique identifier for this event
	ID   string               `json:"id,required" format:"uuid"`
	Data StreamEventDataUnion `json:"data,required"`
	// Type of stream event - system events or log messages
	//
	// Any of "system", "log".
	Type StreamEventType `json:"type,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Data        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

Server-Sent Event emitted during streaming responses. Events are sent as `data: <JSON>\n\n`. Key order: data (with status first), type, id.

func (StreamEvent) RawJSON

func (r StreamEvent) RawJSON() string

Returns the unmodified JSON received from the API

func (*StreamEvent) UnmarshalJSON

func (r *StreamEvent) UnmarshalJSON(data []byte) error

type StreamEventDataStreamEventLogDataOutput

type StreamEventDataStreamEventLogDataOutput struct {
	// Log message from the operation
	Message string           `json:"message,required"`
	Status  constant.Running `json:"status,required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (StreamEventDataStreamEventLogDataOutput) RawJSON

Returns the unmodified JSON received from the API

func (*StreamEventDataStreamEventLogDataOutput) UnmarshalJSON

func (r *StreamEventDataStreamEventLogDataOutput) UnmarshalJSON(data []byte) error

type StreamEventDataStreamEventSystemDataOutput

type StreamEventDataStreamEventSystemDataOutput struct {
	// Current status of the streaming operation
	//
	// Any of "starting", "connected", "running", "finished", "error".
	Status string `json:"status,required"`
	// Error message (present when status is 'error')
	Error string `json:"error"`
	// Operation result (present when status is 'finished')
	Result any `json:"result"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Status      respjson.Field
		Error       respjson.Field
		Result      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (StreamEventDataStreamEventSystemDataOutput) RawJSON

Returns the unmodified JSON received from the API

func (*StreamEventDataStreamEventSystemDataOutput) UnmarshalJSON

func (r *StreamEventDataStreamEventSystemDataOutput) UnmarshalJSON(data []byte) error

type StreamEventDataUnion

type StreamEventDataUnion struct {
	Status string `json:"status"`
	// This field is from variant [StreamEventDataStreamEventSystemDataOutput].
	Error string `json:"error"`
	// This field is from variant [StreamEventDataStreamEventSystemDataOutput].
	Result any `json:"result"`
	// This field is from variant [StreamEventDataStreamEventLogDataOutput].
	Message string `json:"message"`
	JSON    struct {
		Status  respjson.Field
		Error   respjson.Field
		Result  respjson.Field
		Message respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

StreamEventDataUnion contains all possible properties and values from StreamEventDataStreamEventSystemDataOutput, StreamEventDataStreamEventLogDataOutput.

Use the methods beginning with 'As' to cast the union to one of its variants.

func (StreamEventDataUnion) AsStreamEventDataStreamEventLogDataOutput

func (u StreamEventDataUnion) AsStreamEventDataStreamEventLogDataOutput() (v StreamEventDataStreamEventLogDataOutput)

func (StreamEventDataUnion) AsStreamEventDataStreamEventSystemDataOutput

func (u StreamEventDataUnion) AsStreamEventDataStreamEventSystemDataOutput() (v StreamEventDataStreamEventSystemDataOutput)

func (StreamEventDataUnion) RawJSON

func (u StreamEventDataUnion) RawJSON() string

Returns the unmodified JSON received from the API

func (*StreamEventDataUnion) UnmarshalJSON

func (r *StreamEventDataUnion) UnmarshalJSON(data []byte) error

type StreamEventType

type StreamEventType string

Type of stream event - system events or log messages

const (
	StreamEventTypeSystem StreamEventType = "system"
	StreamEventTypeLog    StreamEventType = "log"
)

Directories

Path Synopsis
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
lib
local
Custom code.
Custom code.
Custom code.
Custom code.
packages
shared

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL