List spend

Answers what one of your org's agents has spent, in integer micro-USD.

GET /v1/agent/{ref}/spend

Addresshttps://api.hanzo.ai/v1/agent/{ref}/spend
MethodGET
Operationget_agent_by_ref_spend
AuthAuthorization: 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 = 1);11902000is1); 11902000 is 11.902. Pass by=component to ask for the breakdown by name — it is the one grouping, and the default.

Request

2 fields.

FieldInTypeRequiredDescription
refpathstringyesRef is the agent's public id or its org-unique name.
byquerystring—By groups the answer: "component" is the only grouping today.

Response

StatusBodyMeaning
200agent.spendViewok
defaultproblem-detailsrefused

200 body — 9 fields.

FieldInTypeAlwaysDescription
by_componentbodyobject—ByComponent holds only the components with spend.
by_component.*bodyinteger (int64)—
cap_micro_usdbodyinteger (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_usdbodyinteger (int64)—ConsumedMicroUSD is what has been spent in the current period, in micro-USD.
max_task_micro_usdbodyinteger (int64)—MaxTaskMicroUSD is the ceiling for a single run, in micro-USD.
periodbodystring—Period is the window the cap resets on: day, week or month.
period_started_atbodyinteger (int64)—PeriodStartedAt is when the current period began, as a Unix second.
refbodystring—Ref names the agent this spend belongs to.
remaining_micro_usdbodyinteger (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();
curl https://api.hanzo.ai/v1/agent/<ref>/spend \
  -H "Authorization: Bearer $HANZO_API_KEY"

MCP reaches agent through the agent tool, which names its 38 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_agents"
         }
       }
     }'

Agent API · All Hanzo APIs · Interactive reference

Was this page useful?