> ## Documentation Index
> Fetch the complete documentation index at: https://hub.hcompany.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> H Platform has three products: the Agents API (managed computer-use agents, base URL https://agp.eu.hcompany.ai/api/v2 or https://agp.hcompany.ai/api/v2 for the US), the Models API (Holo computer-use models for your own agent harness, OpenAI-compatible, at https://api.hcompany.ai/v1), and HoloTab (a free no-code Chrome extension that runs Holo in the user's browser, with recordable routines and schedules). The `holo` CLI (`pip install "hai-agents[cli]"`) runs Agents API agents from a terminal, drives the user's own desktop with `-a h/holo-desktop`, and serves coding agents through `holo mcp`.
> Authenticate with a bearer API key from the HAI_API_KEY environment variable. SDKs: `pip install hai-agents` (Python, `from hai_agents import Client`) and `npm install hai-agents` (TypeScript, `import { HaiAgentsClient } from "hai-agents"`). CLI: `holo`.
> Agents do work in a browser or on a desktop; describe the task as an imperative instruction. To run a task quickly, prefer the pre-built agent `h/web-surfer-flash`. Read results from the session's `latest_answer` after it reaches a terminal status.
> Sessions are the unit of work; wait for a terminal status (completed, failed, timed_out, interrupted), or idle for interactive sessions created with `idle_timeout_s`, before reading the answer. Use webhooks or the `changes` long-poll endpoint to follow progress.

# Browser profiles, vaults, and proxies

> Start a cloud browser already signed in with a profile, let the agent fill logins and one-time codes from a vault, and choose where its traffic comes from.

[Profiles →
Start signed in, from saved cookies and site storage.
`browser_profile_id`](#browser-profiles)

[Vaults →
The agent fills logins without seeing them.
`vault_id`](#credentials-and-2fa)

[One-time codes →
Authenticator codes from a vault, email and SMS codes through your code.
`totp, otp_tool`](#handle-two-factor-authentication)

[Proxies →
Choose the network and country traffic exits from.
`network`](#route-through-a-proxy)

Profiles, vaults, and proxies are fields on a [browser](https://hub.hcompany.ai/agents-api/browser/configuration.md#fields), inline in an agent or on a catalog [environment](https://hub.hcompany.ai/agents-api/environments/create.md). One-time codes from an inbox come through a tool you pass to the session. Accessibility mode takes none of these, and only visual mode fills from a vault.

## Browser profiles

A browser profile is a cloud browser's saved state: cookies, local storage, and session data. Load one and the session starts signed in. Name a profile with `browser_profile_id` or follow your [default](#default-profiles), not both.

### Your default profile

Every user has a default profile per browser flavor (for example `chromium`): a browser that remembers you across sessions. You upload nothing and track no IDs.

```python Python theme={"system"}
from hai_agents import Client

client = Client()
client.environments.create_environment(
    request={"id": "acme-browser", "kind": "web", "use_default_browser_profile": True},
)
```

```typescript TypeScript theme={"system"}
import { HaiAgentsClient } from "hai-agents";

const client = new HaiAgentsClient();
await client.environments.createEnvironment({
  body: { id: "acme-browser", kind: "web", useDefaultBrowserProfile: true },
});
```

```bash cURL theme={"system"}
curl -X POST https://agp.eu.hcompany.ai/api/v2/environments \
  -H "Authorization: Bearer $HAI_API_KEY" -H "Content-Type: application/json" \
  -d '{"id": "acme-browser", "kind": "web", "use_default_browser_profile": true}'
```

* If you have no default yet, the session creates an empty profile and marks it as your default when it starts. Sign in to your sites once (for example in the session's [Agent View](https://hub.hcompany.ai/agents-api/observe-and-steer.md#watch-a-session)) and the state carries forward. Delete it and the next default-profile session starts from a fresh empty default.
* Each session writes its final state back when it ends, under the [one-writer rule](#persisting-state-back-into-the-profile).

### Save state back

A profile named with `browser_profile_id` is read-only by default: the session discards whatever it changes (new cookies, refreshed tokens, dismissed banners), so its logins age out. Set `persist_browser_profile: true` to write the final state back when the session ends. Sessions that follow your [default profile](#default-profiles) persist without the flag.

```python Python theme={"system"}
client.environments.create_environment(
    request={
        "id": "acme-browser",
        "kind": "web",
        "browser_profile_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
        "persist_browser_profile": True,
    },
)
```

```typescript TypeScript theme={"system"}
await client.environments.createEnvironment({
  body: {
    id: "acme-browser",
    kind: "web",
    browserProfileId: "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    persistBrowserProfile: true,
  },
});
```

```bash cURL theme={"system"}
curl -X POST https://agp.eu.hcompany.ai/api/v2/environments \
  -H "Authorization: Bearer $HAI_API_KEY" -H "Content-Type: application/json" \
  -d '{
    "id": "acme-browser",
    "kind": "web",
    "browser_profile_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    "persist_browser_profile": true
  }'
```

One session writes to a profile at a time. The first session to persist a profile, by flag or as a default-profile session, holds its write lock until it ends. Later sessions asking to persist still start, but read-only, instead of failing. Any number of sessions can load a profile read-only in parallel.

* Last write wins: the session's final state replaces the stored state.
* Request persistence when creating the session, not when attaching to one.
* If the write-back fails, the session still stops cleanly and the profile keeps its previous state.

### Upload your own profile

Upload a profile when you want to bring logins built outside H. You build a Chrome user-data directory, zip it, and upload it. H keeps only its sign-in data: cookies and site storage (Local Storage, Session Storage, IndexedDB). Extensions, saved passwords and preferences are dropped.

#### Creating a profile

Build a dedicated profile, on Linux, on the runner's Chromium:

* Never upload your personal Chrome directory (`~/Library/Application Support/Google/Chrome` on macOS, `~/.config/google-chrome` on Linux). It holds every password, token, and history entry you have. Treat the archive as a secret.
* Cookies only carry over from Linux builds. On macOS and Windows, Chrome always encrypts cookies with the OS keychain (Keychain or DPAPI), so the profile loads logged out, with site storage only. No flag changes that: build in Docker.
* Sessions run Chromium 150.0.7871.124. A profile built on a newer version does not load.
* Shut Chromium down cleanly. It writes cookies to disk only on a clean shutdown or an occasional autosave. Killing it (`docker stop` sends `SIGTERM`, `docker rm -f` sends `SIGKILL`) can lose the logins you just made.

`--password-store=basic` makes cookies portable: Chrome encrypts them with a built-in key that the session runner also uses. Without it, the agent starts logged out.

> [tab] Docker (any OS)
>
> You need [Docker](https://www.docker.com/). The image tag is pinned to the runner's Chromium, so do not use `:latest`.
>
> ```bash theme={"system"}
> docker run -d --name agent-profile -p 127.0.0.1:3000:3000 \
>   -e CHROME_CLI="--password-store=basic" \
>   -v "$HOME/agent-profile:/config" \
>   lscr.io/linuxserver/chromium:11e602ae-ls45
>
> # Open http://localhost:3000 and sign in to the sites the agent needs.
>
> # Flush cookies with SIGINT, wait, then remove the container and zip.
> docker exec agent-profile pkill -INT -o chromium
> sleep 3
> docker rm -f agent-profile
> cd "$HOME/agent-profile/.config/chromium" && zip -r ~/profile.zip .
> ```

> [tab] Linux Chrome
>
> Use a Chrome no newer than the runner's. It opens a fresh profile, separate from your everyday one.
>
> ```bash theme={"system"}
> google-chrome --user-data-dir="$HOME/agent-profile" --password-store=basic
>
> # Sign in and dismiss cookie banners. Quit Chrome cleanly, then:
> cd "$HOME/agent-profile" && zip -r ~/profile.zip .
> ```

#### Uploading a profile

**1. Initiate the upload**

[`POST /initiate-upload`](https://hub.hcompany.ai/agents-api/browser-profiles/initiate-upload) returns a `profile_id`, a presigned `upload_url`, and the `upload_fields` to send with the file.

```python Python theme={"system"}
from hai_agents import Client

client = Client()

upload = client.browser_profiles.initiate_browser_profile_upload()
```

```typescript TypeScript theme={"system"}
import { HaiAgentsClient } from "hai-agents";

const client = new HaiAgentsClient();

const upload = await client.browserProfiles.initiateBrowserProfileUpload();
```

```bash cURL theme={"system"}
INIT=$(curl -s -X POST https://agp.eu.hcompany.ai/api/v2/browser-profiles/initiate-upload \
  -H "Authorization: Bearer $HAI_API_KEY")
PROFILE_ID=$(echo "$INIT" | jq -r .profile_id)
UPLOAD_URL=$(echo "$INIT" | jq -r .upload_url)
```

**2. Upload the archive to storage**

`POST` the `.zip` to `upload_url` as `multipart/form-data`, with every entry of `upload_fields`, unmodified. The archive must be `application/zip`, at most **1 GB**. The URL and fields expire after `upload_expires_in` seconds, so upload right away.

```python Python theme={"system"}
import requests

with open("profile.zip", "rb") as f:
    resp = requests.post(
        upload.upload_url,
        data=upload.upload_fields,
        files={"file": ("profile.zip", f, "application/zip")},
    )
    resp.raise_for_status()
```

```typescript TypeScript theme={"system"}
import { readFileSync } from "fs";

const form = new FormData();
for (const [key, value] of Object.entries(upload.uploadFields)) {
  form.append(key, value as string);
}
form.append("file", new Blob([readFileSync("profile.zip")]), "profile.zip");
const resp = await fetch(upload.uploadUrl, { method: "POST", body: form });
if (!resp.ok) throw new Error(`upload failed: ${resp.status}`);
```

```bash cURL theme={"system"}
args=()
while IFS= read -r line; do
  args+=(--form-string "$line")
done <<< "$(echo "$INIT" | jq -r '.upload_fields | to_entries[] | "\(.key)=\(.value)"')"

curl -sS --fail-with-body -w "upload: HTTP %{http_code}\n" \
  -X POST "$UPLOAD_URL" "${args[@]}" -F "file=@profile.zip"

# Healthy upload will return `upload: HTTP 204`
```

**3. Complete the upload**

[`POST /{profile_id}/complete-upload`](https://hub.hcompany.ai/agents-api/browser-profiles/complete-upload) with `name`, `browser_name`, and `browser_version` **within 1 day**, or the pending upload is deleted. The platform verifies the archive and creates the profile.

```python Python theme={"system"}
profile = client.browser_profiles.complete_browser_profile_upload(
    profile_id=upload.profile_id,
    name="acme-prod-login",
    browser_name="chromium",
    browser_version="150",
)
print(profile.id)
```

```typescript TypeScript theme={"system"}
const profile = await client.browserProfiles.completeBrowserProfileUpload({
  profileId: upload.profileId,
  name: "acme-prod-login",
  browserName: "chromium",
  browserVersion: "150",
});
console.log(profile.id);
```

```bash cURL theme={"system"}
curl -X POST "https://agp.eu.hcompany.ai/api/v2/browser-profiles/$PROFILE_ID/complete-upload" \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "acme-prod-login", "browser_name": "chromium", "browser_version": "150"}'
```

Load it by setting `browser_profile_id` on the browser. [List, retrieve, or delete](https://hub.hcompany.ai/agents-api/browser-profiles/list.md) your profiles with the browser profile endpoints.

### Choose your own default

Promote a profile you curated (for example one you [uploaded](#upload-your-own-profile)). You can only mark profiles you created yourself. Profile objects report their status in `is_default`.

| Action | Endpoint |
| - | - |
| Set (replaces the previous default for that browser) | [`PUT /browser-profiles/{profile_id}/default`](https://hub.hcompany.ai/agents-api/browser-profiles/set-default) |
| Read | [`GET /browser-profiles/default`](https://hub.hcompany.ai/agents-api/browser-profiles/get-default) |
| Clear | [`DELETE /browser-profiles/{profile_id}/default`](https://hub.hcompany.ai/agents-api/browser-profiles/unset-default) |

## Vaults

A vault holds the logins an agent signs in with, one item per login: the sites it applies to and up to five [fields](#what-an-item-holds). The agent asks for a field such as `password`, the session picks the item from the page URL, and types the value into the page. The agent never sees it.

Vaults work on [cloud browsers](https://hub.hcompany.ai/agents-api/browser/configuration.md#fields) only, since secrets never leave H's infrastructure, and in visual mode, through the [`fill_secret_at`](https://hub.hcompany.ai/agents-api/browser/configuration#visual-actions) action. To start already signed in instead, use a [browser profile](#browser-profiles).

### Set up a vault

Create the vault, then set its `vault_id` on a browser: inline in an agent's `environments`, or on a catalog [environment](https://hub.hcompany.ai/agents-api/environments/create.md).

> [tab] 1Password
>
> The secrets stay in a [1Password](https://developer.1password.com/) vault you own. When the agent fills a field, H fetches the item from 1Password and decrypts it. Pass a [service account token](https://www.1password.dev/service-accounts) for that vault: H validates it against 1Password and never returns it.
>
> ```python Python theme={"system"}
> from hai_agents import Client, VaultCreateRequestProviderConfig_Onepassword
>
> client = Client()
> vault = client.vaults.create_vault(
>     name="prod-1password",
>     provider_config=VaultCreateRequestProviderConfig_Onepassword(op_vault_id="abcd1234efgh5678"),
>     token="ops_eyJ...",
> )
> client.environments.create_environment(request={"kind": "web", "id": "signed-in-browser", "vault_id": vault.id})
> ```
>
> ```typescript TypeScript theme={"system"}
> import { HaiAgentsClient } from "hai-agents";
>
> const client = new HaiAgentsClient();
> const vault = await client.vaults.createVault({
>   name: "prod-1password",
>   providerConfig: { provider: "onepassword", opVaultId: "abcd1234efgh5678" },
>   token: "ops_eyJ...",
> });
> await client.environments.createEnvironment({ body: { id: "signed-in-browser", kind: "web", vaultId: vault.id } });
> ```
>
> ```bash cURL theme={"system"}
> VAULT_ID=$(curl -sX POST https://agp.eu.hcompany.ai/api/v2/vaults \
>   -H "Authorization: Bearer $HAI_API_KEY" -H "Content-Type: application/json" \
>   -d '{
>     "name": "prod-1password",
>     "provider_config": {"provider": "onepassword", "op_vault_id": "abcd1234efgh5678"},
>     "token": "ops_eyJ..."
>   }' | jq -r .id)
>
> curl -X POST https://agp.eu.hcompany.ai/api/v2/environments \
>   -H "Authorization: Bearer $HAI_API_KEY" -H "Content-Type: application/json" \
>   -d "{\"id\": \"signed-in-browser\", \"kind\": \"web\", \"vault_id\": \"$VAULT_ID\"}"
> ```

> [tab] H-hosted
>
> H stores the items you add through the [item endpoints](https://hub.hcompany.ai/agents-api/vaults/create-item.md), one per login. You can read one back with [Reveal an item](https://hub.hcompany.ai/agents-api/vaults/reveal-item.md), which is audit-logged.
>
> ```python Python theme={"system"}
> from hai_agents import Client, VaultCreateRequestProviderConfig_Internal
>
> client = Client()
> vault = client.vaults.create_vault(name="team-logins", provider_config=VaultCreateRequestProviderConfig_Internal())
> client.vaults.create_vault_item(
>     vault_id=vault.id,
>     name="Example admin",
>     urls=["https://example.com/login"],
>     values={"username": "admin@example.com", "password": "s3cret", "totp": "JBSWY3DPEHPK3PXP"},
> )
> client.environments.create_environment(request={"kind": "web", "id": "signed-in-browser", "vault_id": vault.id})
> ```
>
> ```typescript TypeScript theme={"system"}
> import { HaiAgentsClient } from "hai-agents";
>
> const client = new HaiAgentsClient();
> const vault = await client.vaults.createVault({ name: "team-logins", providerConfig: { provider: "internal" } });
> await client.vaults.createVaultItem({
>   vaultId: vault.id,
>   name: "Example admin",
>   urls: ["https://example.com/login"],
>   values: { username: "admin@example.com", password: "s3cret", totp: "JBSWY3DPEHPK3PXP" },
> });
> await client.environments.createEnvironment({ body: { id: "signed-in-browser", kind: "web", vaultId: vault.id } });
> ```
>
> ```bash cURL theme={"system"}
> VAULT_ID=$(curl -sX POST https://agp.eu.hcompany.ai/api/v2/vaults \
>   -H "Authorization: Bearer $HAI_API_KEY" -H "Content-Type: application/json" \
>   -d '{"name": "team-logins", "provider_config": {"provider": "internal"}}' | jq -r .id)
>
> curl -X POST "https://agp.eu.hcompany.ai/api/v2/vaults/$VAULT_ID/items" \
>   -H "Authorization: Bearer $HAI_API_KEY" -H "Content-Type: application/json" \
>   -d '{
>     "name": "Example admin",
>     "urls": ["https://example.com/login"],
>     "values": {"username": "admin@example.com", "password": "s3cret", "totp": "JBSWY3DPEHPK3PXP"}
>   }'
>
> curl -X POST https://agp.eu.hcompany.ai/api/v2/environments \
>   -H "Authorization: Bearer $HAI_API_KEY" -H "Content-Type: application/json" \
>   -d "{\"id\": \"signed-in-browser\", \"kind\": \"web\", \"vault_id\": \"$VAULT_ID\"}"
> ```

List, update, delete, [rotate a 1Password token](https://hub.hcompany.ai/agents-api/vaults/rotate-token.md), or [health-check](https://hub.hcompany.ai/agents-api/vaults/health.md) a vault with the [vault endpoints](https://hub.hcompany.ai/agents-api/vaults/create.md), and manage an H-hosted vault's items with the [item endpoints](https://hub.hcompany.ai/agents-api/vaults/list-items.md).

### What an item holds

An item carries up to five fields, each a value the agent can fill: `username`, `password`, `email`, `totp`, and `api_key`. For `totp`, `fill_secret_at` types the current code, never the secret.

In an H-hosted vault, set them in the item's `values`. For `totp`, store the authenticator secret (base32, or an `otpauth://totp/` URI).

In 1Password, each one maps to a field on the item. Other fields are ignored:

| Field | 1Password item field |
| - | - |
| `username` | Title contains "username" |
| `password` | Password type, title contains "password" |
| `email` | Email type, or title contains "email" |
| `totp` | One-time password type |
| `api_key` | Password type, title contains "api" or "key" |

### How secrets are matched

Agents never name an item. The page URL picks one, from the sites stored on each item (a 1Password item's websites, or an H-hosted item's `urls`), and the agent can fill only that item's fields:

* The page host must equal a stored site's host, or be a subdomain of it.
* The closest host wins: an exact host beats a parent domain, and a deeper subdomain beats a shallower one.
* Among equal hosts, the stored path sharing the most leading segments with the page wins, then the one with the fewest segments the page lacks. A path is never required.
* In an H-hosted vault, items still tied resolve to the most recently created one. Store one item per login to avoid ties.

For a page at `test.hcompany.ai/app/login`:

| Site stored on the item | Rank |
| - | - |
| `test.hcompany.ai` | 1st: exact host |
| `hcompany.ai/app` | 2nd: parent domain, shares `/app` |
| `hcompany.ai` | 3rd: parent domain, no path |
| `hcompany.ai/enterprise` | 4th: its path is not the page's |
| `prod.hcompany.ai` | Never: a sibling host |

## One-time codes

How the agent gets a one-time code depends on where the code shows up.

### Authenticator apps

Store the authenticator's TOTP secret in 1Password, or as an H-hosted item's `totp` value, then [set up the vault](#set-up-a-vault). On a matching page, the session generates the current code and `fill_secret_at` with `totp` types it in. The agent never sees the code.

### Email, SMS, and confirmation links

The SDKs ship a [custom tool](https://hub.hcompany.ai/agents-api/custom-tools.md) for this: the agent calls `request_otp`, your process finds the code or link, and the session continues with that single value. Pass `otp_tool` (`otpTool` in TypeScript) in `tools`, with a handler for where the code arrives:

| The code arrives | Pass |
| - | - |
| At your keyboard | `otp_tool()`: it prompts in your terminal (Node.js only in TypeScript) |
| In an inbox you control | `otp_tool(imap_otp_handler(...))`, for unattended sessions |
| Anywhere else, like Slack or an SMS provider | `otp_tool(fn)`, with your own function, sync or async |

```python Python theme={"system"}
import os

from hai_agents import Client
from hai_agents_tools import imap_otp_handler, otp_tool

inbox = imap_otp_handler(
    host="imap.gmail.com",
    username="agent-inbox@gmail.com",
    password=os.environ["GMAIL_APP_PASSWORD"],
    sender="no-reply@example.com",  # optional: only mail from this address
)

client = Client()
result = client.run_session(
    agent="h/web-surfer-flash",
    messages="Log in to example.com and check for new notifications.",
    tools=[otp_tool(inbox)],  # or otp_tool() to prompt, otp_tool(fn) with your own fn(request) -> str
)
print(result.answer)
```

```typescript TypeScript theme={"system"}
import { HaiAgentsClient, imapOtpHandler, otpTool } from "hai-agents";

// The IMAP handler needs: npm install imapflow mailparser
const inbox = imapOtpHandler({
  host: "imap.gmail.com",
  username: "agent-inbox@gmail.com",
  password: process.env.GMAIL_APP_PASSWORD!,
  sender: "no-reply@example.com", // optional: only mail from this address
});

const client = new HaiAgentsClient();
const result = await client.runSession({
  agent: "h/web-surfer-flash",
  messages: "Log in to example.com and check for new notifications.",
  tools: [otpTool({ handler: inbox })], // or otpTool() to prompt, otpTool({ handler: fn }) with your own async fn(request)
});
console.log(result.answer);
```

#### Read the code from email

The IMAP handler runs in your process. It polls unread mail (newest first), extracts a code or confirmation link, marks that message read so a retry can't reuse a stale code, and returns only that value. IMAP credentials never leave your machine, and the agent never sees mailbox contents, subjects, or senders. For Gmail or Google Workspace, use an [app password](https://support.google.com/accounts/answer/185833).

Every option, with its default:

```python Python theme={"system"}
imap_otp_handler(
    host="imap.gmail.com",          # required, with username and password
    username="agent-inbox@gmail.com",
    password=os.environ["GMAIL_APP_PASSWORD"],
    port=993,                       # IMAP over TLS
    mailbox="INBOX",
    sender=None,                    # only consider mail from this address
    timeout_s=120,                  # then give up, with a tool error to the agent
    poll_interval_s=5,
    max_age_s=900,                  # ignore older unread mail
    mark_seen=True,                 # mark the matched message read
    code_pattern=None,              # regex: first group, or whole match, is the code
)
```

```typescript TypeScript theme={"system"}
imapOtpHandler({
  host: "imap.gmail.com",           // required, with username and password
  username: "agent-inbox@gmail.com",
  password: process.env.GMAIL_APP_PASSWORD!,
  port: 993,                        // IMAP over TLS
  mailbox: "INBOX",
  sender: undefined,                // only consider mail from this address
  timeoutMs: 120_000,               // then give up, with a tool error to the agent
  pollIntervalMs: 5_000,
  maxAgeMs: 900_000,                // ignore older unread mail
  markSeen: true,                   // mark the matched message read
  codePattern: undefined,           // RegExp: first group, or whole match, is the code
});
```

#### What the agent sends

Your handler receives the tool's fixed input schema as an `OtpRequest`:

```python OtpRequest theme={"system"}
OtpRequest(
    prompt="Enter the code sent to j***@example.com",  # always set
    kind="code",                                       # default; or "link" for a confirmation URL
    source="email",                                    # or "sms", "authenticator app"; may be None
)
```

Return a non-empty string. An empty value fails as a tool error, so the agent can retry or stop cleanly.

## Proxies

Use a proxy when a site blocks datacenter IPs or geofences by region, or when a session needs traffic from a specific network. Set `network` to exactly one of `managed_proxy` or `proxy_url`.

### Managed proxy

H provisions the proxy. You pick pool, country, and stickiness. H resolves credentials server-side, so they never appear in your requests, session data, or logs.

```python Python theme={"system"}
from hai_agents import Client

client = Client()
result = client.run_session(
    agent={
        "name": "us-shopper",
        "description": "Browses from a US residential IP.",
        "environments": [{
            "id": "us-browser",
            "kind": "web",
            "network": {
                "managed_proxy": {
                    "pool": "residential",  # default; or "datacenter", "isp", "mobile"
                    "country": "US",        # two-letter ISO 3166-1 code; omit for any location
                    "sticky": True,         # default: same exit IP all session
                },
            },
        }],
    },
    messages="Open bestbuy.com and report the price of the cheapest 65-inch TV.",
)
print(result.answer)
```

```typescript TypeScript theme={"system"}
import { HaiAgentsClient } from "hai-agents";

const client = new HaiAgentsClient();
const result = await client.runSession({
  agent: {
    name: "us-shopper",
    description: "Browses from a US residential IP.",
    environments: [{
      id: "us-browser",
      kind: "web",
      network: {
        managedProxy: {
          pool: "residential", // default; or "datacenter", "isp", "mobile"
          country: "US",       // two-letter ISO 3166-1 code; omit for any location
          sticky: true,        // default: same exit IP all session
        },
      },
    }],
  },
  messages: "Open bestbuy.com and report the price of the cheapest 65-inch TV.",
});
console.log(result.answer);
```

```bash cURL theme={"system"}
curl -X POST https://agp.eu.hcompany.ai/api/v2/sessions \
  -H "Authorization: Bearer $HAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": {
      "name": "us-shopper",
      "description": "Browses from a US residential IP.",
      "environments": [{
        "id": "us-browser",
        "kind": "web",
        "network": {"managed_proxy": {"pool": "residential", "country": "US", "sticky": true}}
      }]
    },
    "messages": "Open bestbuy.com and report the price of the cheapest 65-inch TV."
  }'
```

Residential addresses come from real ISPs, best for sites that block datacenter ranges. A pool not available in your environment fails with `400`, an invalid country with `422`. `sticky` applies to residential pools only: datacenter endpoints rotate on their own.

### Bring your own proxy

For a proxy you already operate, set its URL with credentials inline. HTTP, HTTPS, and SOCKS schemes work. Treat the value as a secret.

```json Bring your own theme={"system"}
"network": { "proxy_url": "http://user:pass@proxy.example.com:8080" }
```

To reuse a proxied browser across agents, [create it in your catalog](https://hub.hcompany.ai/agents-api/environments/create.md) with the same `network` object.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.