Skip to main content
Docs
Usage

Usage

Retrieve current-period usage and token counts for your organization, plus your own credit balance.

Returns what your organization has spent this billing period, how many tokens that came to, and what credit you have left. Use it to surface spend inside your own dashboard, or to alert before a balance runs dry.

Endpoint

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

Authentication

This is a Platform API endpoint — OAuth JWT plus organization header, not an elyxir_ key.

HeaderRequiredDescription
AuthorizationYesBearer <oauth-jwt>
X-Organization-IdYesYour organization UUID

Example

curl https://api.elyxir.ai/api/v1/usage \
  -H "Authorization: Bearer <oauth-jwt>" \
  -H "X-Organization-Id: 00000000-0000-0000-0000-000000000000"

Response

{
  "organization": {
    "id": "00000000-0000-0000-0000-000000000000",
    "name": "Acme Corp",
    "slug": "acme-corp",
    "plan": "standard"
  },
  "currentPeriod": {
    "start": "2026-08-01T00:00:00.000Z",
    "end": "2026-09-01T00:00:00.000Z"
  },
  "usage": {
    "totalCost": "12.45",
    "totalTokens": 2450000,
    "promptTokens": 1800000,
    "completionTokens": 650000
  },
  "limits": {
    "inferenceTokensLimit": 5000000
  },
  "credits": {
    "scope": "user",
    "userId": "11111111-1111-1111-1111-111111111111",
    "currentBalance": 37.55,
    "spendableMicros": 37550000,
    "netMicros": 37550000,
    "unallocatedDebtMicros": 0,
    "lotOverdrawMicros": 0,
    "openLots": 2,
    "nextExpiresAt": "2027-01-14T00:00:00.000Z"
  }
}

Fields

FieldDescription
organization.planCurrent plan code
currentPeriodThe billing window these figures cover
usage.totalCostSpend this period, in USD, as a string
usage.totalTokensPrompt plus completion tokens
limitsCeilings that apply on this plan. Additional keys may appear here over time — read the ones you need rather than assuming the shape is fixed
credits.scopeAlways "user". The credit block describes the authenticated caller, not the organization
credits.userIdThe user whose wallet these figures belong to
credits.currentBalanceSpendable credit in USD, rounded to cents and never negative. Display only
credits.spendableMicrosThe same figure in integer micro-USD (1 USD = 1,000,000), floored at zero
credits.netMicrosSpendable credit minus outstanding debt, in micro-USD, not floored — this one can be negative. Test this, not currentBalance, when deciding whether an account can spend
credits.unallocatedDebtMicrosUsage charged against no credit at all, in micro-USD. Zero for most accounts
credits.lotOverdrawMicrosUsage that drew a credit amount past empty, in micro-USD. Zero for most accounts
credits.openLotsHow many unexpired credit lots remain
credits.nextExpiresAtWhen the soonest-expiring lot dies, or null if nothing on the account expires

Credit expires now

Credit is held in lots, each of which dies on a fixed date (six months from purchase by default). An account that spends nothing can still reach a zero balance. openLots and nextExpiresAt are there so you can warn before that happens; a balance that drops with no matching usage is expiry, not an error.

Removed fields

credits.totalPurchased and credits.totalSpent were removed when credit moved to the per-user ledger. They reported an organization's lifetime purchased-versus-spent pair, and the ledger no longer keeps such a pair for anyone — it tracks live lots, debt and overdraw. There is no replacement, and nothing in the new response should be summed to reconstruct them: a lot total is current credit, not lifetime purchases. For lifetime history, record snapshots yourself or use the cost dashboard.

Errors

StatusMeaning
401Invalid or expired JWT
403Not a member of this organization
502The credit ledger could not be read (code: "balance_service_unavailable"). Retry — this is never reported as a zero balance

Notes

Figures cover the current billing period and reset when it rolls over. If you need a longer history, record snapshots yourself — or use the cost dashboard in Studio, which retains history and breaks spend down by model and project.

Usage | Alvin