List spend
Answers what one of your org's agents has spent, in integer micro-USD.
GET /v1/agent/{ref}/spend
| Address | https://api.hanzo.ai/v1/agent/{ref}/spend |
| Method | GET |
| Operation | get_agent_by_ref_spend |
| Auth | Authorization: Bearer $HANZO_API_KEY |
Answers what one of your org's agents has spent, in integer micro-USD.
It answers the agent's budget — cap_micro_usd per period,
max_task_micro_usd per run — with what the current period has consumed,
what remains, and by_component: the spend attributed to model (every
completion the agent bought), computer (the runtime it was resident for)
and tool. A component with no spend is absent, not zero. Every amount is an
integer number of micro-USD (1,000,000 = 11.902. Pass
by=component to ask for the breakdown by name — it is the one grouping, and
the default.
Request
2 fields.
| Field | In | Type | Required | Description |
|---|---|---|---|---|
ref | path | string | yes | Ref is the agent's public id or its org-unique name. |
by | query | string | — | By groups the answer: "component" is the only grouping today. |
Response
| Status | Body | Meaning |
|---|---|---|
200 | agent.spendView | ok |
default | problem-details | refused |
200 body — 9 fields.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
by_component | body | object | — | ByComponent holds only the components with spend. |
by_component.* | body | integer (int64) | — | |
cap_micro_usd | body | integer (int64) | — | CapMicroUSD is the total this agent may spend within one Period, as an integer number of micro-USD (1,000,000 = $1). |
consumed_micro_usd | body | integer (int64) | — | ConsumedMicroUSD is what has been spent in the current period, in micro-USD. |
max_task_micro_usd | body | integer (int64) | — | MaxTaskMicroUSD is the ceiling for a single run, in micro-USD. |
period | body | string | — | Period is the window the cap resets on: day, week or month. |
period_started_at | body | integer (int64) | — | PeriodStartedAt is when the current period began, as a Unix second. |
ref | body | string | — | Ref names the agent this spend belongs to. |
remaining_micro_usd | body | integer (int64) | — | RemainingMicroUSD is what the cap still allows this period, in micro-USD. |
Failure carries the platform error shape — see Errors.
Examples
hanzo agent spend <ref>import { Configuration, AgentApi } from 'hanzoai';
const api = new AgentApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.getAgentByRefSpend({ ref: 'ref' });from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import AgentApi
client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = AgentApi(client).get_agent_by_ref_spend(ref='ref')cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)
resp, _, err := client.AgentAPI.GetAgentByRefSpend(context.Background()).Execute()
if err != nil {
return err
}use hanzo_client::apis::{configuration::Configuration, agent_api};
let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();
let result = agent_api::get_agent_by_ref_spend(&cfg, Default::default()).await?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.AgentApi;
ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));
var result = new AgentApi(client).getAgentByRefSpend();The method above is the one at the current release of the document. [email protected] (npm) was 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/agent/<ref>/spend \
-H "Authorization: Bearer $HANZO_API_KEY"MCP reaches agent through the agents tool, which names its 36 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_agent_conversations"
}
}
}'How is this guide?