aiUsage
query · in the family Billing and the wallet
What it does
Your group’s AI usage by day — calls, tokens, and what your plan meters for it, with a per-surface breakdown.
Your group's AI usage by UTC day: composed off the daily rollup rows the meter grows with every metered call (calls · tokens · what your plan meters — billedKernels, and billedUsd at the standard rate — + the per-surface split), ≤ 92 bounded point-reads — never a scan. Self-group BY construction (no target arg exists — the tokenEntries stance); days defaults 30, clamps 1..92; only days with usage answer (an empty window is the honest answer). billedUsd values are decimal strings (the money-string law). Requires authentication.
Before you call
A bearer session from an API key (see Authentication and key hygiene) or a signed-in user.
Capability area: Billing and the wallet — Your platform bill, token purchases and the usage and cost reads.
Roles that may call it:
- Owner
- Manager
- Associate Manager
- An API key whose scope allows
api:aiUsage
What happens
A read over the running usage counters the platform keeps for every AI call; your cost shows as what your plan meters for it — kernels, and the USD at the standard rate (volume tiers price lower). A day counted before that figure was kept shows no cost yet. Only days with usage appear.
Arguments
| Name | Type | Required | Notes |
|---|---|---|---|
days | Int | no |
Returns
AiUsageWindow AiUsageWindow! — Your group's AI-usage window: the days with usage, newest first, + the window totals.
Example request
query ExampleAiUsage($days: Int) {
aiUsage(days: $days) {
totalCalls
totalTokensInput
totalTokensOutput
totalBilledKernels
totalBilledUsd
}
}Variables:
{
"days": 1
}Example response
{
"data": {
"aiUsage": {
"totalCalls": 1,
"totalTokensInput": 1,
"totalTokensOutput": 1,
"totalBilledKernels": 1.5,
"totalBilledUsd": "<total billed usd>"
}
},
"extensions": {
"at": {
"callId": "01EXAMPLE-CALL-ID",
"version": {
"requested": null,
"serviced": {
"name": "genesis",
"number": 0
}
}
}
}
}Errors this call can answer
VALIDATION/INVALID— Something in the request is not valid. Retry: no. (VALIDATION)AUTHN/REQUIRED— Sign in to do this. Retry: no. (AUTHN)AUTHZ/FORBIDDEN— Your role does not allow this action. Retry: no. (AUTHZ)RATE_LIMIT/THROTTLED— Too many requests in a short time. Retry: yes. (RATE_LIMIT)