useAiCredits
Refetched every time it mounts, because other apps spend from the same pool. CalluseRefreshAiCredits() after your own app spends.
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 withcode: '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().