v1
latestOpenAPI 3.1.02026-07-265817860.8 KBRecords AI token usage for a customer and returns the updated AI credit balance.
Use this after an LLM request when you have input and output token counts. Autumn converts token usage to a dollar amount using the configured model pricing and markup, then tracks that value against the customer's AI credit system.
post/v1/balances.track_tokens
Headers
x-api-versionstring required
Request body
Example request
{
"customer_id": "cus_123",
"feature_id": "ai_credits",
"model_id": "anthropic/claude-sonnet-4-20250514",
"input_tokens": 1000,
"output_tokens": 500
}Response
OK
Example response
{
"customer_id": "cus_123",
"value": 0.006,
"balance": {
"feature_id": "ai_credits",
"granted": 10,
"remaining": 9.994,
"usage": 0.006,
"unlimited": false,
"overage_allowed": false,
"max_purchase": null,
"next_reset_at": 1773851121437,
"breakdown": [
{
"id": "cus_ent_39qmLooixXLAqMywgXywjAz96rV",
"plan_id": "pro_plan",
"included_grant": 100,
"prepaid_grant": 0,
"remaining": 72,
"usage": 28,
"unlimited": false,
"reset": {
"interval": "month",
"resets_at": 1773851121437
},
"price": null,
"expires_at": null
}
]
},
"deductions": [
{
"balance_id": "cus_ent_3DdSDoyFmoA9Neecl2a2Gc507X2",
"feature_id": "ai_credits",
"plan_id": "pro",
"reset": {
"interval": "month",
"resets_at": 1781288736881
},
"value": 0.006
}
]
}