RaabtaHQ
Get AI usage

Get AI usage

GET/api/v1/ai/usage

scope ai:usageCosts 2 rate-limit units

What the AI has cost over the last 7, 30 or 90 days, broken down by feature, by model and by which credential paid. Figures are what the account is billed, so they match the invoice rather than the provider’s raw price.

Query parameters

NameTypeDescription
daysoptional
string (enum)Window length. Defaults to 3073090
Request
curl "https://your-crm.example.com/api/v1/ai/usage?days=30" \
  -H "Authorization: Bearer $RAABTA_API_KEY"
Response · 200 OK
{
  "data": {
    "days": 30,
    "total_cost_usd": 42.18,
    "total_calls": 1834,
    "total_requests": 2210,
    "total_input_tokens": 5920400,
    "total_output_tokens": 411200,
    "total_cached_input_tokens": 3100000,
    "daily": [
      {
        "date": "2026-09-01",
        "cost_usd": 1.62,
        "calls": 71,
        "requests": 84,
        "input_tokens": 228000,
        "output_tokens": 15800,
        "cached_input_tokens": 119000
      }
    ],
    "by_feature": [
      {
        "key": "assistant",
        "cost_usd": 38.9,
        "calls": 1702,
        "requests": 2044,
        "input_tokens": 5512000,
        "output_tokens": 380100,
        "cached_input_tokens": 2980000
      }
    ],
    "by_model": [
      {
        "key": "claude-sonnet-5",
        "cost_usd": 38.9,
        "calls": 1702,
        "requests": 2044,
        "input_tokens": 5512000,
        "output_tokens": 380100,
        "cached_input_tokens": 2980000
      }
    ],
    "by_source": [
      {
        "key": "platform",
        "cost_usd": 42.18,
        "calls": 1834,
        "requests": 2210,
        "input_tokens": 5920400,
        "output_tokens": 411200,
        "cached_input_tokens": 3100000
      }
    ]
  }
}

Response

Wrapped in { data: … }
NameTypeDescription
daysrequired
integerWindow length in days: 7, 30 or 90
total_cost_usdrequired
numberBilled spend over the window
total_callsrequired
integerCalls over the window
total_requestsrequired
integerProvider requests over the window
total_input_tokensrequired
integerTokens sent over the window
total_output_tokensrequired
integerTokens returned over the window
total_cached_input_tokensrequired
integerCached input tokens over the window
dailyrequired
object[]Zero-filled, oldest day first
daily[].daterequired
stringThe day, as YYYY-MM-DD in UTC
daily[].cost_usdrequired
numberBilled spend that day
daily[].callsrequired
integerCalls that day
daily[].requestsrequired
integerProvider requests that day
daily[].input_tokensrequired
integerTokens sent that day
daily[].output_tokensrequired
integerTokens returned that day
daily[].cached_input_tokensrequired
integerCached input tokens that day
by_featurerequired
object[]Costliest first
by_feature[].keyrequired
stringThe feature, model or source this row aggregates
by_feature[].cost_usdrequired
numberBilled spend
by_feature[].callsrequired
integerAssistant ticks and one-shot calls
by_feature[].requestsrequired
integerProvider HTTP requests
by_feature[].input_tokensrequired
integerTokens sent
by_feature[].output_tokensrequired
integerTokens returned
by_feature[].cached_input_tokensrequired
integerInput tokens served from the provider cache
by_modelrequired
object[]Costliest first
by_model[].keyrequired
stringThe feature, model or source this row aggregates
by_model[].cost_usdrequired
numberBilled spend
by_model[].callsrequired
integerAssistant ticks and one-shot calls
by_model[].requestsrequired
integerProvider HTTP requests
by_model[].input_tokensrequired
integerTokens sent
by_model[].output_tokensrequired
integerTokens returned
by_model[].cached_input_tokensrequired
integerInput tokens served from the provider cache
by_sourcerequired
object[]business is your own provider key; platform is capacity we served
by_source[].keyrequired
stringThe feature, model or source this row aggregates
by_source[].cost_usdrequired
numberBilled spend
by_source[].callsrequired
integerAssistant ticks and one-shot calls
by_source[].requestsrequired
integerProvider HTTP requests
by_source[].input_tokensrequired
integerTokens sent
by_source[].output_tokensrequired
integerTokens returned
by_source[].cached_input_tokensrequired
integerInput tokens served from the provider cache

Errors

StatusCodeWhen
400bad_requestThe request could not be parsed: malformed JSON, an invalid cursor, or a query parameter of the wrong shape.
400validation_errorThe body or query failed validation. `details` lists each failing field with a `path` and a `message`.
401unauthorizedNo usable API key: the Authorization header is missing or malformed, or the key is unknown, revoked or expired. The three are deliberately indistinguishable.
403forbiddenThe key is valid but lacks the scope this endpoint requires, or the request came from an address outside the key’s IP allowlist. The message says which.
403account_suspendedThe account this key belongs to is suspended. Rotating the key will not help; contact support.
429rate_limitedThe per-key budget, or the per-IP budget for failed authentication, is exhausted. Honour `Retry-After` before retrying.
500internalSomething failed on our side. Safe to retry with the same Idempotency-Key; quote `request_id` if it persists.