Skip to main content

A plain-language prompt driving a browser agent from Python (add_to_cart.py)

Call the API directly over HTTP, use a typed client, or connect any MCP host. The clients and CLI ship as hai-agents.

Python

Sync and async clients, typed with Pydantic v2.

TypeScript

A fully typed client for sessions, agents, skills, environments, schedules, and webhooks.

Install

Authenticate

Set HAI_API_KEY in your environment, or pass the key explicitly. Either way the client attaches it to every call as a bearer token. If you don’t have a key yet, create one first.
Each endpoint’s reference page has a playground that runs in your browser and shows raw HTTP, handy for exploring the wire format; the shared conventions are on the API reference. Use the SDK snippets here and in the Quickstart for code you’d ship.

Client configuration

Region

The clients default to the EU host. Requests stay in-region; the hosts are listed on the API reference. To target the US region, pass it explicitly:

Retries

The clients retry transient errors with backoff, twice by default. Set max_retries (Python) / maxRetries (TypeScript) on the client, or per call via request options. Which codes count as transient is on Errors.

Async client

Python ships AsyncClient with the same surface as Client, awaited. Session handles from it support async for on stream(). Structured output uses it to run agents in parallel with asyncio.gather. The TypeScript client is async throughout.

Examples

The hcompai/computer-use-agents-demos repo collects recipes for the hai-agents SDK. Each one runs on its own and is wired up as an MCP server, a CLI tool, or both, so you can call the agents from Claude Code, Cursor, Codex, or Hermes.

See it in action

QA a live page from Claude Code: “Use review_web_ui to check the top story link works and the page has reasonable accessibility.”

Autonomous QA of a web page via the review_web_ui MCP tool

The video at the top of this page drives the agent straight from a natural-language prompt in Python: “Search for ‘Random Access Memories’ by Daft Punk, add it to the shopping cart.” Runnable code: examples/add_to_cart/add_to_cart.py

Next steps

MCP server

Run and manage agents from Cursor, Claude Code, Codex, Hermes, and more, with no SDK code.

Coding assistants

Install the hai-agents skill so Claude Code, Cursor, and other assistants know the H APIs and scaffold use cases for you.

Quickstart

Run your first session end to end in under 5 minutes.

Agents

Reusable configurations: pre-built agents and how to create your own.