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

> ## Agent Instructions
> Authenticate REST, SDK, and CLI requests with the `x-api-key` header using the `HYPERBROWSER_API_KEY` environment variable (create keys at https://app.hyperbrowser.ai).
> Always stop browser sessions (`sessions.stop(id)` / `PUT /api/session/{id}/stop`) and sandboxes (`sandboxes.stop(id)` / `PUT /api/sandbox/{id}/stop`) in `try`/`finally` blocks to avoid idle billing.
> Choose the right surface: use Web API (`/api/web/fetch`, `batch-fetch`, `crawl`, `search`) for stateless reading and extraction (prefer it over legacy `/api/scrape`); Browser Sessions (`/api/session`) for interactive, authenticated, or Playwright/Puppeteer workflows; Cloud Agents (`/api/task/*`) for autonomous browser tasks; and Sandboxes (`/api/sandbox`) for isolated Linux or macOS code execution.
> Use `@hyperbrowser/sdk` for Node.js/TypeScript, `hyperbrowser` 1.0+ typed-dict request params for Python (avoid legacy Pydantic request classes), the unified `hx` CLI for terminal workflows, and hosted OAuth MCP at `https://mcp.hyperbrowser.ai/mcp/web` (web tools; use `https://mcp.hyperbrowser.ai/mcp` only when browser, sandbox, admin, and usage tools are needed).

# Usage & Credits

> Monitor team credit balances, per-job usage, and cost optimization practices

Hyperbrowser bills all services—Browser Sessions, Web API, Cloud Agents, and Sandboxes—from a unified **credit** balance:

* \*\*1 credit = $0.001** (1,000 credits = $1.00).
* Subscription plan credits refresh each billing cycle; directly purchased top-up credits expire after 12 months.

For exact per-product rates (browser memory tiers, vCPU/memory sandbox rates, proxy bandwidth, Web API, and agent steps), see [Pricing](https://hyperbrowser.ai/docs/pricing.md).

***

## Check Team Credit Balance

Query your team's current credit usage, limit, and remaining balance with `GET /api/team/credit-info` (requires the `usage.read` scope on scoped API keys).

```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { Hyperbrowser } from "@hyperbrowser/sdk";

const client = new Hyperbrowser({
  apiKey: process.env.HYPERBROWSER_API_KEY,
});

const credits = await client.team.getCreditInfo();
console.log({
  usage: credits.usage,
  limit: credits.limit,
  remaining: credits.remaining,
});
```

```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import os
from hyperbrowser import Hyperbrowser

client = Hyperbrowser(api_key=os.environ["HYPERBROWSER_API_KEY"])

credits = client.team.get_credit_info()
print(credits.usage, credits.limit, credits.remaining)
```

```bash cURL theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl https://api.hyperbrowser.ai/api/team/credit-info \
  -H "x-api-key: $HYPERBROWSER_API_KEY"
```

### Response

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "usage": 14250,
  "limit": 100000,
  "remaining": 85750
}
```

| Field | Type | Description |
| - | - | - |
| `usage` | `number` | Credits consumed in the current billing window. |
| `limit` | `number` | Total credit allowance available (plan credits plus active top-ups). |
| `remaining` | `number` | Credits remaining before requests begin returning `402`. |

***

## Inspect Per-Job Usage

Check credits, page counts, agent steps, and token totals for any completed Web API or Agent job with `GET /api/usage/job/{jobId}` (requires `usage.read`).

```bash cURL theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
curl https://api.hyperbrowser.ai/api/usage/job/<JOB_ID> \
  -H "x-api-key: $HYPERBROWSER_API_KEY"
```

### Response

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "creditsUsed": 6,
  "successfulPagesScraped": 1,
  "numTaskStepsCompleted": 0,
  "inputTokens": 1240,
  "outputTokens": 185,
  "totalTokens": 1425
}
```

| Field | Description |
| - | - |
| `creditsUsed` | Total credits billed for the job. |
| `successfulPagesScraped` | Number of pages successfully processed (Web API & legacy scraping jobs). |
| `numTaskStepsCompleted` | Number of agent steps completed (Cloud Agent tasks). |
| `inputTokens`, `outputTokens`, `totalTokens` | LLM token usage recorded when the job invoked extraction or agent models. |

***

## Cost Optimization Best Practices

> [accordion] Always stop sessions and sandboxes in try/finally
>
> Browser sessions are billed per millisecond while active (no minimum duration), and sandboxes are billed while running. Always call `sessions.stop(id)` or `sandboxes.stop(id)` in a `finally` block instead of waiting for `timeoutMinutes` to expire.

> [accordion] Use caching on Web API calls
>
> Set `cache.maxAgeSeconds` on [Fetch](https://hyperbrowser.ai/docs/web/fetch.md), [Batch Fetch](https://hyperbrowser.ai/docs/web/batch-fetch.md), and [Crawl](https://hyperbrowser.ai/docs/web/crawl.md) (or `maxAgeSeconds` on [Search](https://hyperbrowser.ai/docs/web/search.md)) when reading pages that do not change every second.

> [accordion] Enable proxies, ultra stealth, and JSON extraction only when needed
>
> A standard Fetch costs 1 credit/page; enabling a proxy adds +9 credits/page and JSON extraction adds +5 credits/page. Start with `stealth: "auto"` (or `"none"` on open sites) and enable `stealth: "ultra"` or `browser.location` only on protected or geo-sensitive targets.

> [accordion] Right-size browser memory and sandbox resources
>
> Keep `browserMemorySize` at `small` (4 GiB, 1× rate) unless heavy tabs require `medium` (2×) or `large` (4×). For sandboxes, match vCPU and memory tiers to the actual workload and stop idle instances promptly.

> [accordion] Monitor balances
>
> Poll `GET /api/team/credit-info` in monitoring alerts before hitting zero remaining credits.


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