AI Consumption

Totals and breakdowns of AI consumption

GET
/api/ai-consumption/summary

Aggregate totals plus breakdowns by type, model, user and name, and a time series for charting. Uses the same filters as the row list so a chart and the table beneath it cannot disagree.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Query Parameters

from?string

Start of the range (inclusive), ISO-8601. Defaults to 30 days ago.

Formatdate-time
to?string

End of the range (exclusive), ISO-8601. Defaults to now.

Formatdate-time
sourceType?string

Value in

  • "ai_agent"
  • "ai_generation"
  • "ai_classification"
  • "ai_summarization"
  • "ai_extraction"
  • "ai_sentiment"
  • "tovi"
  • "voice_agent"
mode?string

Traffic class. Omitted means production only - playground, simulation, preview and node-test spend is recorded but excluded from totals by default.

Value in

  • "production"
  • "playground"
  • "simulation"
  • "preview"
  • "node_test"
model?string
provider?string
userId?string

Acting user. System-initiated work is recorded under an explicit system actor.

sourceName?string

Case-insensitive substring match against the display-name snapshot.

search?string

Free text matched case-insensitively against the source name, model, provider, acting user and type. Narrows the other filters rather than replacing them. Spaces and underscores are interchangeable, so the displayed 'AI Agent' matches the stored ai_agent.

status?string

Restrict to successful or failed calls. A failed call still spent input tokens and is recorded, so this is how those are reached in a large result set.

Value in

  • "success"
  • "error"
organizationId?string

SUPERADMIN only. all returns a cross-organization view, which is distinct from omitting the parameter (the caller’s own organization). Ignored for every other role.

interval?string

Bucket width for the time series.

Default"day"

Value in

  • "hour"
  • "day"
  • "week"

Response Body

application/json

curl -X GET "https://example.com/api/ai-consumption/summary"
{  "success": true,  "data": {    "from": "2019-08-24T14:15:22Z",    "to": "2019-08-24T14:15:22Z",    "mcpToolCalls": 0,    "totals": {      "calls": 0,      "inputTokens": 0,      "outputTokens": 0,      "cacheReadTokens": 0,      "cacheWriteTokens": 0,      "reasoningTokens": 0,      "totalTokens": 0,      "inputCost": 0,      "outputCost": 0,      "reasoningCost": 0,      "totalCost": 0,      "durationMs": 0    },    "byType": [      {        "calls": 0,        "inputTokens": 0,        "outputTokens": 0,        "cacheReadTokens": 0,        "cacheWriteTokens": 0,        "reasoningTokens": 0,        "totalTokens": 0,        "inputCost": 0,        "outputCost": 0,        "reasoningCost": 0,        "totalCost": 0,        "durationMs": 0,        "key": "string",        "label": "string"      }    ],    "byModel": [      {        "calls": 0,        "inputTokens": 0,        "outputTokens": 0,        "cacheReadTokens": 0,        "cacheWriteTokens": 0,        "reasoningTokens": 0,        "totalTokens": 0,        "inputCost": 0,        "outputCost": 0,        "reasoningCost": 0,        "totalCost": 0,        "durationMs": 0,        "key": "string",        "label": "string"      }    ],    "byUser": [      {        "calls": 0,        "inputTokens": 0,        "outputTokens": 0,        "cacheReadTokens": 0,        "cacheWriteTokens": 0,        "reasoningTokens": 0,        "totalTokens": 0,        "inputCost": 0,        "outputCost": 0,        "reasoningCost": 0,        "totalCost": 0,        "durationMs": 0,        "key": "string",        "label": "string"      }    ],    "byName": [      {        "calls": 0,        "inputTokens": 0,        "outputTokens": 0,        "cacheReadTokens": 0,        "cacheWriteTokens": 0,        "reasoningTokens": 0,        "totalTokens": 0,        "inputCost": 0,        "outputCost": 0,        "reasoningCost": 0,        "totalCost": 0,        "durationMs": 0,        "key": "string",        "label": "string"      }    ],    "timeseries": [      {        "calls": 0,        "inputTokens": 0,        "outputTokens": 0,        "cacheReadTokens": 0,        "cacheWriteTokens": 0,        "reasoningTokens": 0,        "totalTokens": 0,        "inputCost": 0,        "outputCost": 0,        "reasoningCost": 0,        "totalCost": 0,        "durationMs": 0,        "at": "2019-08-24T14:15:22Z",        "sourceType": "string"      }    ]  }}