AI Consumption

List AI consumption records

GET
/api/ai-consumption

One row per billable AI model invocation, across agents, workflow AI nodes, automations, background extraction, Tovi and voice. Each row carries the token counts, the cost, and the per-million rates the cost was computed from, so a total is reproducible after model prices change. Admin and superadmin only.

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.

sortBy?string

Column to order by. Defaults to most recent first.

Default"startedAt"

Value in

  • "startedAt"
  • "cost"
  • "tokens"
  • "duration"
sortDir?string
Default"desc"

Value in

  • "asc"
  • "desc"
page?integer
Range1 <= value
Default1
limit?integer
Range1 <= value <= 100
Default20

Response Body

application/json

curl -X GET "https://example.com/api/ai-consumption"
{  "success": true,  "data": [    {      "_id": "string",      "organizationId": "string",      "environment": "string",      "invocationId": "string",      "attempt": 0,      "parentInvocationId": "string",      "sourceType": "ai_agent",      "sourceId": "string",      "sourceName": "string",      "agentId": "string",      "workflowId": "string",      "workflowNodeId": "string",      "conversationId": "string",      "callId": "string",      "actor": {        "kind": "user",        "userId": "string",        "userName": "string"      },      "surface": "in_app",      "mode": "production",      "provider": "string",      "model": "string",      "tokens": {        "input": 0,        "output": 0,        "cacheRead": 0,        "cacheWrite": 0,        "reasoning": 0,        "total": 0      },      "cost": {        "input": 0,        "output": 0,        "cacheRead": 0,        "cacheWrite": 0,        "reasoning": 0,        "total": 0,        "currency": "string",        "credits": 0      },      "pricing": {        "source": "catalog",        "pricedAt": "2019-08-24T14:15:22Z",        "inputPerM": 0,        "outputPerM": 0,        "cacheReadPerM": 0,        "cacheWritePerM": 0,        "usdPerCredit": 0      },      "startedAt": "2019-08-24T14:15:22Z",      "completedAt": "2019-08-24T14:15:22Z",      "durationMs": 0,      "status": "success",      "errorCode": "string",      "backfill": {        "source": "string",        "runId": "string",        "action": "insert",        "at": "2019-08-24T14:15:22Z",        "insertRunId": "string"      }    }  ],  "pagination": {    "page": 0,    "limit": 0,    "total": 0,    "totalPages": 0  }}