Skip to main content

Installation

npm install @hyperbrowser/agent

Choose Your LLM Provider

HyperAgent needs an LLM to power its AI capabilities. We recommend setting environment variables for your API keys.
export OPENAI_API_KEY="sk-..."

Your First Automation

Create a file called demo.ts:
import { HyperAgent } from "@hyperbrowser/agent";

async function main() {
  // Initialize the agent
  const agent = new HyperAgent({
    llm: {
      provider: "openai",
      model: "gpt-5.1",
    },
  });

  // Create a new browser page
  const page = await agent.newPage();

  // Navigate and automate
  await page.goto("https://news.ycombinator.com");
  
  const result = await page.ai(
    "Find the top story and tell me the title and point count"
  );

  console.log(result.output);

  // Remember to close the agent when you're done, otherwise the session will stay open.
  await agent.closeAgent();
}

main();
Run it:
npx tsx demo.ts

CLI Mode

For quick one-off tasks, use the CLI:
npx @hyperbrowser/agent -c "Go to google.com and search for 'best pizza in NYC'"
CLI Options:
FlagDescription
-c, --command <task>Natural language command to run
-d, --debugEnable debug mode with verbose output
--hyperbrowserUse Hyperbrowser cloud instead of local browser

Get Started with 3 Core Methods

HyperAgent gives you three ways to interact with pages:

1. page.ai() — Complex Tasks

For multi-step workflows where AI makes decisions:
await page.ai("search for flights from Miami to LAX, select the cheapest option");

2. page.perform() — Single Actions

For fast, specific actions:
await page.perform("click the login button");
await page.perform("fill email with [email protected]");

3. page.extract() — Data Extraction

For pulling structured data:
import { z } from "zod";

const data = await page.extract(
  "get the product details",
  z.object({
    name: z.string(),
    price: z.number(),
    rating: z.number(),
  })
);

Mix and Match

The real power comes from combining these methods:
const page = await agent.newPage();
await page.goto("https://amazon.com");

// Fast, single-action execution
await page.perform("click the search box");
await page.perform("type 'mechanical keyboard'");
await page.perform("press Enter");

// AI handles the complex part
await page.ai("search for keyboards under $100");

// Extract structured data
const product = await page.extract(
  "Select the first product from the search results",
  z.object({
    name: z.string(),
    price: z.number(),
    rating: z.number(),
  })
);

console.log(product);

Scale to the Cloud

When you’re ready to run at scale, switch to Hyperbrowser:
const agent = new HyperAgent({
  browserProvider: "Hyperbrowser", // That's it!
});
You’ll need a HYPERBROWSER_API_KEY. Get one free at app.hyperbrowser.ai.

Next Steps