List samples

The PER-PROVIDER view: one connected account's own consumption of its own plan — "my plan is 47% through its 6h window, resets at 14:20".

GET /v1/usage/samples

Addresshttps://api.hanzo.ai/v1/usage/samples
MethodGET
Operationget_usage_samples
AuthAuthorization: Bearer $HANZO_API_KEY

The PER-PROVIDER view: one connected account's own consumption of its own plan — "my plan is 47% through its 6h window, resets at 14:20".

current is the newest instance of each lane (the headline); windows is the history behind it. Both come from ONE deduped read, so they can never disagree. The rows are the caller's OWN linked accounts, scoped to the validated principal and its subject — never another user's, and never another org's.

Request

4 fields.

FieldInTypeRequiredDescription
accountquerystring—Account narrows to ONE linked account of that provider.
providerquerystring—Provider is the upstream to read, e.g. anthropic.
rangequerystring—Range is the window to read: a count and a unit — 1h, 24h, 90d, any <N>h or <N>d — or day, week, month, all.
windowquerystring—Window narrows to ONE window class: 6h, day, week or month.

Response

StatusBodyMeaning
200usage.dashRespok
defaultproblem-detailsrefused

200 body — 48 fields.

FieldInTypeAlwaysDescription
accountbodystring—Account is the linked account that was asked about, when one was named.
availablebodyboolean—Available is false when the warehouse could not be read.
currentbodyusage.usageWindowView[]—Current is the newest window instance of each lane — the dash headline.
current[].accountbodystring—Account is the linked provider account the window belongs to.
current[].cachedInputTokensbodyinteger (int64)—CachedInputTokens is the prompt tokens served from the provider's cache; omitted when unknown.
current[].confidencebodystring—Confidence says how much the counters beside it mean — a meter that reported only a percentage leaves them at zero, and this is how a reader tells that from a true zero.
current[].costCentsbodyinteger (int64)—CostCents is what the window cost on the PROVIDER's own plan, in US cents.
current[].costLimitCentsbodyinteger (int64)—CostLimitCents is the plan's spend ceiling for the window, in US cents.
current[].currencybodystring—Currency is the provider's currency when it is not US cents.
current[].inputTokensbodyinteger (int64)—InputTokens is prompt tokens consumed in the window; omitted when unknown.
current[].lanebodystring—Lane is the meter lane this instance belongs to, e.g. a provider's own rolling-window meter.
current[].machinebodystring—Machine is the host whose meter reported the window.
current[].outputTokensbodyinteger (int64)—OutputTokens is completion tokens produced in the window; omitted when unknown.
current[].planbodystring—Plan is the subscription plan the account is on, as the provider names it.
current[].requestsbodyinteger (int64)—Requests is how many requests were made in the window; omitted when the meter did not report it.
current[].resetsAtbodystring—ResetsAt is when this window rolls over, RFC3339 UTC; omitted when unknown.
current[].syntheticbodyboolean—Synthetic marks an instance the meter inferred rather than read.
current[].totalTokensbodyinteger (int64)—TotalTokens is the window's total tokens; omitted when unknown.
current[].usedPctbodynumber (double)—UsedPct is how much of the window's allowance is consumed, 0–100.
current[].windowbodystring—Window is the window class: 6h, day, week or month.
current[].windowMinutesbodyinteger (int32)—WindowMinutes is the window's real length in minutes when the meter reported one; omitted when it did not.
current[].windowStartbodystring—WindowStart is when this window opened, RFC3339 UTC; omitted when unknown.
frombodystring—From is the inclusive start of that window, RFC3339 UTC.
providerbodystring—Provider is the upstream that was asked about, echoed back.
rangebodystring—Range is the window that was served: 1h, 24h, 7d or 30d.
scopebodystring—Scope says whose rows these are: the caller's own linked accounts.
sourcebodystring—Source names the meter of record — the provider's own login, not Hanzo.
tobodystring—To is the exclusive end of that window, RFC3339 UTC.
windowsbodyusage.usageWindowView[]—Windows is every instance in range, newest first — the history behind it.
windows[].accountbodystring—Account is the linked provider account the window belongs to.
windows[].cachedInputTokensbodyinteger (int64)—CachedInputTokens is the prompt tokens served from the provider's cache; omitted when unknown.
windows[].confidencebodystring—Confidence says how much the counters beside it mean — a meter that reported only a percentage leaves them at zero, and this is how a reader tells that from a true zero.
windows[].costCentsbodyinteger (int64)—CostCents is what the window cost on the PROVIDER's own plan, in US cents.
windows[].costLimitCentsbodyinteger (int64)—CostLimitCents is the plan's spend ceiling for the window, in US cents.
windows[].currencybodystring—Currency is the provider's currency when it is not US cents.
windows[].inputTokensbodyinteger (int64)—InputTokens is prompt tokens consumed in the window; omitted when unknown.
windows[].lanebodystring—Lane is the meter lane this instance belongs to, e.g. a provider's own rolling-window meter.
windows[].machinebodystring—Machine is the host whose meter reported the window.
windows[].outputTokensbodyinteger (int64)—OutputTokens is completion tokens produced in the window; omitted when unknown.
windows[].planbodystring—Plan is the subscription plan the account is on, as the provider names it.
windows[].requestsbodyinteger (int64)—Requests is how many requests were made in the window; omitted when the meter did not report it.
windows[].resetsAtbodystring—ResetsAt is when this window rolls over, RFC3339 UTC; omitted when unknown.
windows[].syntheticbodyboolean—Synthetic marks an instance the meter inferred rather than read.
windows[].totalTokensbodyinteger (int64)—TotalTokens is the window's total tokens; omitted when unknown.
windows[].usedPctbodynumber (double)—UsedPct is how much of the window's allowance is consumed, 0–100.
windows[].windowbodystring—Window is the window class: 6h, day, week or month.
windows[].windowMinutesbodyinteger (int32)—WindowMinutes is the window's real length in minutes when the meter reported one; omitted when it did not.
windows[].windowStartbodystring—WindowStart is when this window opened, RFC3339 UTC; omitted when unknown.

Failure carries the platform error shape — see Errors.

Examples

hanzo usage samples
import { Configuration, UsageApi } from 'hanzoai';

const api = new UsageApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getUsageSamples();
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import UsageApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = UsageApi(client).get_usage_samples()
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.UsageAPI.GetUsageSamples(context.Background()).Execute()
if err != nil {
	return err
}
use hanzo_client::apis::{configuration::Configuration, usage_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = usage_api::get_usage_samples(&cfg, Default::default()).await?;
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.UsageApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new UsageApi(client).getUsageSamples();
curl https://api.hanzo.ai/v1/usage/samples \
  -H "Authorization: Bearer $HANZO_API_KEY"

MCP reaches usage through the usage tool, which names its 5 operations with its own verbs — this one among them, under a name only MCP declares. describe explains any of them:

curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_usage_analytics"
         }
       }
     }'

Usage API · All Hanzo APIs · Interactive reference

Was this page useful?