Account
Get usage
Read runs, tokens and estimated cost for the current billing period.
GET
/
api
/
v2
/
usage
from hai_agents import Client
client = Client()
usage = client.usage.get_usage(scope="me")
print(usage.totals.tokens)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const usage = await client.usage.getUsage({ scope: "me" });
console.log(usage.totals.tokens);
curl "https://agp.eu.hcompany.ai/api/v2/usage?scope=me" \
-H "Authorization: Bearer $HAI_API_KEY"
Query parameters
me for your usage, or members for the organization’s usage split by member. Only organization owners can request members.Response
200 with an object containing:
| Field | Type | Meaning |
|---|---|---|
window_start | string | ISO 8601 start of the billing period. |
window_end | string or null | ISO 8601 end, when known. |
client | string or null | The requested client filter. |
totals | object | runs and tokens (integers), and cost_usd_estimate (number). |
daily | object[] | For me: the same counts per UTC date (YYYY-MM-DD). |
members | object[] | For members: the same counts per user_id (string). |
from hai_agents import Client
client = Client()
usage = client.usage.get_usage(scope="me")
print(usage.totals.tokens)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const usage = await client.usage.getUsage({ scope: "me" });
console.log(usage.totals.tokens);
curl "https://agp.eu.hcompany.ai/api/v2/usage?scope=me" \
-H "Authorization: Bearer $HAI_API_KEY"
Errors
403 for scope=members without owner access. See common errors.Was this page helpful?
⌘I
from hai_agents import Client
client = Client()
usage = client.usage.get_usage(scope="me")
print(usage.totals.tokens)
import { HaiAgentsClient } from "hai-agents";
const client = new HaiAgentsClient();
const usage = await client.usage.getUsage({ scope: "me" });
console.log(usage.totals.tokens);
curl "https://agp.eu.hcompany.ai/api/v2/usage?scope=me" \
-H "Authorization: Bearer $HAI_API_KEY"