const agent = stagehand.agent();
 await agent.execute("Sign me up for a library card");

Software has always been deterministic and repeatable, but with AI agents it’s difficult to replicate a workflow. Stagehand combines the best of both worlds: intelligence and determinism.

Web Agents in Stagehand are fully customizable. You can use any LLM / VLM / Computer Use provider, set system prompts, add custom tools, and more.

// For Computer Use Agent (CUA) models
const agent = stagehand.agent({
  provider: "openai",
  model: "computer-use-preview",
  instructions: "You are a helpful assistant that can use a web browser.",
  options: {
    apiKey: process.env.OPENAI_API_KEY,
  },
});

Arguments: AgentOptions

provider
string
required

Specifies the LLM provider. Currently supporting:

  • OpenAI: openai
  • Anthropic: anthropic
model
string
required

Specifies the LLM model. Currently supporting:

  • OpenAI: computer-use-preview
  • Anthropic: claude-3-7-sonnet-20250219 and claude-3-5-sonnet-20240620
instructions
string

Specifies the system prompt

options
object

Configuration options for the LLM provider. Currently supports OpenAI and Anthropic SDK client options.

Returns: Promise<AgentResult>

success
boolean

If the agent execution completed without errors

message
string

Summary or error message from the agent

actions
AgentAction[]

List of actions performed during execution

completed
boolean

Whether the agent fully completed its task (can be false even if success is true)

metadata
Record<string, unknown>

Optional additional data about the execution