Skip to content
API reference

Get usage

Reference for GET /api/v1/usage, which returns your requests and spending by day and by model.

This page is the reference for the usage endpoint of the Management API. It is intended for developers who track spending or build cost reports.

Endpoint

GET https://engy.ai/api/v1/usage

Authentication

Send your account token in the Authorization header as a bearer token. For details, see Management API overview.

Parameters

Query parameters

ParameterTypeRequiredDescription
daysIntegerNoThe window in days. Accepted values are 7 and 30. Defaults to 30.
modelStringNoReturns usage for this model ID only. An unknown model ID returns empty results, not an error.

Response

Response fields

FieldTypeDescription
data.totalObjectThe totals for the whole window.
data.by_dayArrayThe totals per UTC day, in ascending order.
data.by_day[].day_startIntegerThe start of the day, as a Unix timestamp in seconds.
data.by_modelArrayThe totals per model, sorted by cost in descending order.
data.by_model[].modelStringThe model ID.
requestsIntegerThe number of requests. Appears in each total.
cost_microIntegerThe amount spent, in micro-USD. Appears in each total.
cost_usdStringThe amount spent, in USD, with two decimal places. Appears in each total.
meta.daysIntegerThe applied window.
meta.modelString or nullThe applied model filter, or null.

Usage covers complete UTC days only, up to and including the previous day.

Errors

CodeStatusCause
invalid_request400The value of days is not 7 or 30.

For the common errors, see Management API overview.

Example

curl "https://engy.ai/api/v1/usage?days=7&model=glm-5.2" \
  -H "Authorization: Bearer $ENGY_ACCOUNT_TOKEN"

Response:

{
  "data": {
    "total": {"requests": 1200, "cost_micro": 3400000, "cost_usd": "3.40"},
    "by_day": [
      {"day_start": 1792281600, "requests": 180, "cost_micro": 510000, "cost_usd": "0.51"}
    ],
    "by_model": [
      {"model": "glm-5.2", "requests": 1200, "cost_micro": 3400000, "cost_usd": "3.40"}
    ]
  },
  "meta": {
    "days": 7,
    "model": "glm-5.2"
  }
}