Breaks down what the gateway routed through each of your accounts.
Breaks down what the gateway routed through each of your accounts.
GET /v1/link/usage/accounts
| Address | https://api.hanzo.ai/v1/link/usage/accounts |
| Method | GET |
| Operation | get_link_usage_accounts |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Breaks down what the gateway routed through each of your accounts.
It answers one row per linked account the GATEWAY actually routed through, plus their total — requests, prompt and completion tokens, and cost. This is the routed ledger, the read twin of the counter the router writes, and it is distinct from both of its neighbours: not the device collector's plan snapshots, and not the org money ledger. The source and scope fields on the response say so on every payload. The same shape answers in the billing namespace, from one shaping function, so the two mounts cannot drift.
Request
GET /v1/link/usage/accounts takes no parameters and no body — the credential is the whole request.
Response
| Status | Body | Meaning |
|---|---|---|
200 | AccountsUsage | ok |
200 body — 19 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
accounts | body | RoutedUsage[] | — | Accounts is one row per linked account the gateway actually routed through. |
accounts[].account | body | string | — | Account is the provider-side account identifier. |
accounts[].billing | body | string | — | Billing is how the routed inference bills: plan or commerce. |
accounts[].completionTokens | body | integer | — | CompletionTokens is the routed completion-token count. |
accounts[].costCents | body | integer | — | CostCents is the routed cost in cents. |
accounts[].kind | body | string | — | Kind is how the account authenticates: subscription or apikey. |
accounts[].promptTokens | body | integer | — | PromptTokens is the routed prompt-token count. |
accounts[].provider | body | string | — | Provider is the AI provider the row's account belongs to. |
accounts[].requests | body | integer | — | Requests is how many requests the gateway routed through this account. |
accounts[].totalTokens | body | integer | — | TotalTokens is the routed total token count. |
scope | body | string | — | Scope is always "user": the caller's own linked accounts. |
source | body | string | — | Source is always "routed": the gateway's own routed ledger. |
total | body | AccountsTotal | — | |
total.accounts | body | integer | — | Accounts is how many linked accounts the total folds. |
total.completionTokens | body | integer | — | CompletionTokens is the total completion-token count. |
total.costCents | body | integer | — | CostCents is the total cost in cents. |
total.promptTokens | body | integer | — | PromptTokens is the total prompt-token count. |
total.requests | body | integer | — | Requests is the total request count the gateway routed. |
total.totalTokens | body | integer | — | TotalTokens is the total token count. |
Failure carries the platform error shape — see Errors.
Examples
hanzo links usage accountsimport { Configuration, LinkApi } from 'hanzoai';
const api = new LinkApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getLinkUsageAccounts();from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import LinkApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = LinkApi(client).get_link_usage_accounts()cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.LinkAPI.GetLinkUsageAccounts(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::apis::{configuration::Configuration, link_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = link_api::get_link_usage_accounts(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.LinkApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new LinkApi(client).getLinkUsageAccounts();The method above is the one at the current release of the document. [email protected] (npm) and [email protected] (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. SDKs →
curl https://api.hanzo.ai/v1/link/usage/accounts \
-H "Authorization: Bearer $HANZO_API_KEY"The door reaches link through the link tool, which names its 11 operations with its own verbs — this one among them, under a name only the door 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_links"
}
}
}'How is this guide?