Skip to main content
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

pip install "hai-agents[cli]"
pip install hai-agents
npm install hai-agents

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.
hai login   # browser sign-in; stores the key in ~/.config/hai/.env
from hai_agents import Client

client = Client()
# or pass it explicitly: Client(api_key="hk-...")
import { HaiAgentsClient } from "hai-agents";

const client = new HaiAgentsClient();
// or pass it explicitly: new HaiAgentsClient({ apiKey: "hk-..." })
The API reference playground runs in your browser and shows raw HTTP, handy for exploring the wire format. Use the SDK snippets here and in the Quickstart for code you’d ship.

Region

H runs isolated EU and US regions. Requests stay in-region, so an EU key only ever reaches EU infrastructure (data residency). The REST API lives under /api/v2 and the MCP server under /mcp on each region’s host:
RegionHost
EU (default)https://agp.eu.hcompany.ai
UShttps://agp.hcompany.ai
The clients default to the EU host. To target another region, pass it explicitly:
from hai_agents import Client, HaiAgentsEnvironment

client = Client(environment=HaiAgentsEnvironment.US)
import { HaiAgentsClient, HaiAgentsEnvironment } from "hai-agents";

const client = new HaiAgentsClient({ environment: HaiAgentsEnvironment.Us });

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.
ExampleWhat it showsInterface
qa/mcpAn autonomous browser agent QAs a remote URL and returns a structured {verdict, summary, findings}MCP server (review_web_ui, visual_check)
qa/cliThe same QA agent exposed as a shell command, surfaced to Claude Code via the hai-qa-via-cli skillCLI (qa-cli review / visual)
extract_anythingWrap an agent call as a typed function: a generic extract(url, task, schema) or curated get_* toolsMCP server (extract) + CLI (extract-cli)
counterfeit_detectionA custom-tools cookbook in three stages: bare run_session, then local screenshot-compare tools, then a max_steps / max_time_s budget for an exhaustive sweepCLI (counterfeit-cli simple / tooled / sweep)

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.”
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.