Run Hyperbrowser with Instant

Hyperbrowser runs the open-source browser-use agent or HyperAgent in a browser you open, with a live view and a saved profile. This page is part of Run browser agents with Instant. Before you start, follow Set up the project there: turn on Instant, install the SDK, and set COMPOSIO_API_KEY and COMPOSIO_USER_ID.

The script opens a browser for one user, runs a small task on https://example.com, prints the result, and then cleans up everything it created. Every script starts with a run() helper that executes one tool on the user's Instant account and raises if the call fails; the API scripts use an equivalent call helper and a trap that cleans up on exit. If a call fails, read Errors you may see.

HYPERBROWSER_CREATE_SESSION opens a browser for the user's profile and returns its live_url immediately. Run tasks on it with session_id and keep_browser_open, then poll HYPERBROWSER_GET_BROWSER_USE_TASK_STATUS until it ends; its last response holds the answer. HYPERBROWSER_STOP_SESSION closes the browser and saves its cookies into the profile.

What the example contains

PartWhat it does
Profile
HYPERBROWSER_CREATE_PROFILE
Stores the user's cookies. Create it once per user and keep its id.
Browser
HYPERBROWSER_CREATE_SESSION
Opens a browser with the profile loaded. timeout_minutes is required and sets how long the browser can run. persist_changes: true saves cookies back when the browser stops. Returns id and live_url.
Live viewlive_url is available as soon as the browser opens. Embed it in an iframe.
Task
HYPERBROWSER_START_BROWSER_USE_TASK
Runs the open-source browser-use agent on your task in that browser. max_steps caps the agent's steps; keep_browser_open lets you run more tasks on the same browser. Returns the task id.
Status loop
HYPERBROWSER_GET_BROWSER_USE_TASK_STATUS
Reads status until it is completed, failed, or stopped.
ResultWhen the status is final, the same status response holds the answer in data.final_result and the agent's steps in data.steps.
Cleanup
HYPERBROWSER_STOP_SESSION, HYPERBROWSER_DELETE_PROFILE
Stopping the browser saves cookies into the profile. Stop before you delete the profile.
hyperbrowser.py
import os
import time

from composio import Composio

composio = Composio()
session = composio.create(
    user_id=os.environ["COMPOSIO_USER_ID"], toolkits=["hyperbrowser"]
)


def run(slug: str, arguments: dict) -> dict:
    result = session.execute(
        slug, arguments=arguments, account="instant_account"
    )
    if result.result_type != "completed":
        raise RuntimeError(f"{slug} failed: {result.error}")
    return result.data


# Once per end user: a profile keeps their sign-ins between browsers.
profile_id = run("HYPERBROWSER_CREATE_PROFILE", {})["id"]
try:
    browser = run(
        "HYPERBROWSER_CREATE_SESSION",
        {
            "timeout_minutes": 5,
            "profile": {"id": profile_id, "persist_changes": True},
        },
    )
    print("Live view:", browser["live_url"])
    try:
        task = run(
            "HYPERBROWSER_START_BROWSER_USE_TASK",
            {
                "task": "Open https://example.com and return the page title.",
                "session_id": browser["id"],
                "keep_browser_open": True,
                "max_steps": 5,
            },
        )
        while True:
            status = run(
                "HYPERBROWSER_GET_BROWSER_USE_TASK_STATUS",
                {"run_id": task["id"]},
            )
            if status["status"] in ("completed", "failed", "stopped"):
                break
            time.sleep(3)
        print(status["status"], status["data"]["final_result"])
    finally:
        # Stopping the browser saves its cookies into the profile.
        run("HYPERBROWSER_STOP_SESSION", {"session_id": browser["id"]})
finally:
    run("HYPERBROWSER_DELETE_PROFILE", {"profile_id": profile_id})

HYPERBROWSER_START_HYPER_AGENT_TASK and its status and result tools follow the same pattern with HyperAgent. max_steps caps the agent's steps, so keep it small.

All tools in this toolkit

Every Hyperbrowser tool you can call with the Instant account. Proxies, CAPTCHA solving, extensions, and custom model keys are refused on Instant. Required arguments are listed; open a tool in the toolkit catalog for every argument and response field.

Agent tasks

ToolWhat it doesRequired arguments
HYPERBROWSER_GET_BROWSER_USE_TASK_RESULTDeprecated. Use HYPERBROWSER_GET_BROWSER_USE_TASK_STATUS, which also returns the answer.run_id
HYPERBROWSER_GET_BROWSER_USE_TASK_STATUSRetrieve the current status of a browser-use task.run_id
HYPERBROWSER_GET_HYPER_AGENT_TASK_RESULTRetrieve the status and results of a HyperAgent task.run_id
HYPERBROWSER_GET_HYPER_AGENT_TASK_STATUSGet the current status of a HyperAgent task.run_id
HYPERBROWSER_START_BROWSER_USE_TASKStart an asynchronous browser-use task.task
HYPERBROWSER_START_HYPER_AGENT_TASKStart an asynchronous HyperAgent browser task.task
HYPERBROWSER_STOP_BROWSER_USE_TASKStop a running browser-use task.run_id
HYPERBROWSER_STOP_HYPER_AGENT_TASKStop a running HyperAgent task.run_id

Browser sessions

ToolWhat it doesRequired arguments
HYPERBROWSER_CREATE_SESSIONCreate a new browser session with custom stealth, proxy, and privacy settings.None
HYPERBROWSER_GET_SESSION_DETAILSRetrieve details of a Hyperbrowser session by ID, including status and configuration.session_id
HYPERBROWSER_GET_SESSION_DOWNLOADS_URLRetrieve the downloads URL for a session.session_id
HYPERBROWSER_GET_SESSION_RECORDINGRetrieve a browser session's rrweb recording status and, when available, a pre-signed download URL.session_id
HYPERBROWSER_GET_SESSION_VIDEO_RECORDING_URLRetrieve a browser session's video recording status and, when available, a pre-signed download URL.session_id
HYPERBROWSER_STOP_SESSIONStop a running session by ID.session_id

Profiles

ToolWhat it doesRequired arguments
HYPERBROWSER_CREATE_PROFILECreates a new persistent Hyperbrowser profile for storing browser state (cookies, sessions, etc.).None
HYPERBROWSER_DELETE_PROFILEDelete a profile.profile_id
HYPERBROWSER_FORK_PROFILECopy an existing browser profile and its stored browser state into a new profile.id
HYPERBROWSER_GET_PROFILERetrieves details of a specific Hyperbrowser profile by its UUID.profile_id
HYPERBROWSER_LIST_PROFILESList profiles.None

Scrape, crawl and search

ToolWhat it doesRequired arguments
HYPERBROWSER_CREATE_SCRAPE_JOBInitiate a new scrape job.url
HYPERBROWSER_FETCH_WEB_PAGEFetch a web page and return content in various formats (HTML, Markdown, JSON, screenshot, etc.).url
HYPERBROWSER_GET_SCRAPE_JOB_RESULTRetrieves the status and results of a scrape job.id
HYPERBROWSER_GET_SCRAPE_JOB_STATUSRetrieve the current status of a specific scrape job.id
HYPERBROWSER_GET_WEB_CRAWL_RESULTRetrieve the status and results of a web crawl job.id
HYPERBROWSER_GET_WEB_CRAWL_STATUSRetrieve just the status of a web crawl job without the full results.id
HYPERBROWSER_SEARCH_WEBPerform a web search and retrieve results with titles, URLs, and descriptions.query
HYPERBROWSER_START_WEB_CRAWLStart an asynchronous web crawl job from a starting URL, with options to follow links and configure content extraction.url

Try it with your own task

Replace the task in the script with your own. For example:

Search https://en.wikipedia.org for "Ada Lovelace" and return the first sentence of the article.

Next steps