Skip to main content
Set up a browser environment, create an agent, run it on a task, and read its answer. All you need is an API key. To skip the setup and just watch a task run, one call to the built-in h/web-surfer-flash agent does it (see the introduction).
1

Install the client

Install the hai-agents client (and CLI). Pick a language below; it applies to every code block on this page.
2

Get your API key

Create a key at platform.hcompany.ai/settings/api-keys. It’s shown only once, so store it securely and keep it server-side. The key is scoped to your organization: everything you create with it is private to that org.Set it as HAI_API_KEY in your environment. Raw HTTP sends it as a bearer token in the Authorization header; the CLI and SDKs pick it up automatically.
3

Create an environment

An environment is what your agent sees and acts on. Register a web browser in visual mode, where the agent works from screenshots and clicks by coordinates, and give it an id the agent will reference.
4

Create an agent

Create an agent that references the environment by id, so you can reuse it across sessions. Agents you create have no prefix; H’s pre-built agents and environments use the reserved h/ namespace (like h/web-surfer-flash and h/browser). The optional instructions shape how the agent behaves on every run:
5

Run a session

Launch a session against web-navigator and describe the task in plain language. Google Flights is a good test: its date picker, filters, and result cards only respond to real clicks, so the agent has to drive the page.The CLI and SDK calls below create the session and block until the final answer. Over raw HTTP there’s no single blocking call, so you create the session, long-poll changes until it reaches a terminal state, then read the settled answer off the session snapshot.
Need live progress instead of one blocking call? Poll status for state and step count, or long-poll changes to stream events as they happen.
6

Watch it on the platform

Open the H Platform to see your sessions: watch a running one step by step, or scrub a finished run to replay the full trajectory. See Agent View for details.

Next steps

Agents

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

Environments

The surfaces your agent perceives and acts on. Browser today; more in What’s next.

Skills

Reusable instruction fragments you can attach to agents.

Sessions

The session lifecycle and how to interact with a running agent.