Skip to main content
Every cskn user has one monthly pool of AI credits, shared by all apps. Each AI action has a fixed price. Show the price next to the button and the remaining balance below it, so the user knows what an action costs before taking it.

useAiCredits

Refetched every time it mounts, because other apps spend from the same pool. Call useRefreshAiCredits() after your own app spends.
number
This month’s spend, cap and balance.
string
The month, YYYY-MM in UTC.
string
ISO time of the next reset: the first of next month, UTC.
Record<string, number>
Credits per action, keyed app.feature, for example { 'ask.message': 1 }.
boolean
While false, the server counts spending but never refuses a request.
Your app sees totals only. How much other apps spent is never returned to it.

Handling a refusal

When the pool is empty, AI endpoints answer 402 with code: 'AI_CREDITS_EXHAUSTED'. aiCreditsExhausted(error) returns that body, or null for any other error. The 402 body also carries feature, cost, used, limit and remaining. Without React, use getAiCredits().