LogoLogo
SupportDashboard
  • Community
  • Welcome to Hyperbrowser
  • Get Started
    • Quickstart
      • AI Agents
        • Browser Use
        • Claude Computer Use
        • OpenAI CUA
      • Web Scraping
        • Scrape
        • Crawl
        • Extract
      • Browser Automation
        • Puppeteer
        • Playwright
        • Selenium
  • Agents
    • Browser Use
    • Claude Computer Use
    • OpenAI CUA
  • HyperAgent
    • About HyperAgent
      • HyperAgent SDK
      • HyperAgent Types
  • Quickstart
  • Multi-Page actions
  • Custom Actions
  • MCP Support
    • Tutorial
  • Examples
    • Custom Actions
    • LLM support
    • Cloud Support
      • Setting Up
      • Proxies
      • Profiles
    • MCP Examples
      • Google Sheets
      • Weather
        • Weather Server
    • Output to Schema
  • Web Scraping
    • Scrape
    • Crawl
    • Extract
  • Sessions
    • Overview
      • Session Parameters
    • Advanced Privacy & Anti-Detection
      • Stealth Mode
      • Proxies
      • Static IPs
      • CAPTCHA Solving
      • Ad Blocking
    • Profiles
    • Recordings
    • Live View
    • Extensions
    • Downloads
  • Guides
    • Model Context Protocol
    • Scraping
    • AI Function Calling
    • Extract Information with an LLM
    • Using Hyperbrowser Session
    • CAPTCHA Solving
  • Integrations
    • ⛓️LangChain
    • 🦙LlamaIndex
  • reference
    • Pricing
    • SDKs
      • Node
        • Sessions
        • Profiles
        • Scrape
        • Crawl
        • Extensions
      • Python
        • Sessions
        • Profiles
        • Scrape
        • Crawl
        • Extensions
    • API Reference
      • Sessions
      • Scrape
      • Crawl
      • Extract
      • Agents
        • Browser Use
        • Claude Computer Use
        • OpenAI CUA
      • Profiles
      • Extensions
Powered by GitBook
On this page
Export as PDF

Quickstart

Get started with HyperAgent in minutes.

PreviousHyperAgent TypesNextMulti-Page actions

Last updated 1 month ago

1

Create a Project

npm init -y
yarn init -y
2

Install HyperAgent and dependencies

npm install dotenv @hyperbrowser/agent @langchain/openai ts-node
yarn add dotenv @hyperbrowser/agent @langchain/openai ts-node
3

Setup files and environment

To use HyperAgent, you will need to connect to a langchain LLM provider. In this example, we'll be using @langchain/openai to use the gpt-4o model. For this, you'll want to setup a .env file with the OPENAI_API_KEY env var like this

OPENAI_API_KEY=sk-proj-abcd1234

Additionally, create a src directory, along with a index.ts file in it.

4

Setting up a task

The task we're running here is fairly simple. The web agent will perform a navigation to , and then perform a content extraction on that page. That extracted content will then be analyzed by gpt-4o to get the relevant content to complete task.

Insert this code into src/index.ts

import "dotenv/config";
import HyperAgent from "@hyperbrowser/agent";
import { ChatOpenAI } from "@langchain/openai";

async function runEval() {
  console.log("\n===== Running Hackernews Example =====");

  const llm = new ChatOpenAI({
    apiKey: process.env.OPENAI_API_KEY,
    model: "gpt-4o",
  });

  const agent = new HyperAgent({
    llm: llm,
  });

  const result = await agent.executeTask(
    "Navigate to hackernews, list me the 3 most recent articles.",
    {
      onStep: (step) => {
        console.log(`===== STEP ${step.idx} =====`);
        console.dir(step, { depth: null, colors: true });
        console.log("===============\n");
      },
    }
  );
  await agent.closeAgent();
  console.log("\nResult:");
  console.log(result.output);
  return result;
}

runEval().catch(console.error);
5

Running the task

npx ts-node src/index.ts 
yarn ts-node src/index.t

And that's it! You've created and run your first web agent

https://news.ycombinator.com/