Skip to main content
Use the account billing and activity endpoints to monitor spend and operational usage. Both endpoints require a provisioning key.

Endpoints at a glance

EndpointWhat it returns
GET /v1/account/balanceCurrent account balance
GET /v1/account/activity?days=NRequests, token usage, costs, top models, and per-key activity

Why These Endpoints Matter

Use them to:
  • monitor remaining funds before expensive operations
  • analyze usage by model, day, or API key
  • build internal dashboards or budget alerts
  • attribute spend across projects or environments

Get Balance

import requests

response = requests.get(
    "https://api.naga.ac/v1/account/balance",
    headers={"Authorization": "Bearer YOUR_PROVISIONING_KEY"},
)
response.raise_for_status()

balance = response.json()
print(balance["balance"])
Response shape:
{
  "balance": "42.50"
}
The balance is returned as a string representing a USD amount.

Get Activity

import requests

response = requests.get(
    "https://api.naga.ac/v1/account/activity",
    headers={"Authorization": "Bearer YOUR_PROVISIONING_KEY"},
    params={"days": 7},
)
response.raise_for_status()

activity = response.json()
print(activity["total_stats"]["total_requests"])
print(activity["total_stats"]["total_cost"])
The activity payload includes:
  • total requests and total cost
  • token usage
  • daily breakdowns
  • top models
  • per-key usage
Use the optional days query parameter to control the lookback window. The supported range is 1-30, with a default of 30. Results are cached briefly for performance, so clients should avoid assuming fully uncached real-time aggregation.

Practical Uses

  • trigger low-balance alerts
  • find the most expensive model families in the last week or month
  • compare production vs staging usage if each environment has its own API key
  • attribute spend back to teams or internal services