How Credits Work
Credit accounting happens in three stages tied to the lifecycle of each generation:- Reserve — When you submit a generation via
POST /generate, estudjo immediately reserves the required credits from your balance. The credits are held but not yet fully spent. - Spend — When the generation completes successfully, the reserved amount is confirmed as a spend charge. The reservation converts to a permanent deduction.
- Release — If the generation fails for any reason, the reserved credits are released back to your balance in full. You are never charged for a failed generation.
Credits Ledger
Every generation object returned byGET /generations includes a credits_logs array. This array gives you a full audit trail of every credit movement associated with that generation.
Each log entry has three log types:
Example: Completed Generation
A successfully completed generation will have both areserve and a spend entry:
Reading the Logs
Use the combination of log entries to determine the current state of a generation’s billing:reserveonly → The generation is still pending; credits are held but not yet settled.reserve+spend→ The generation completed successfully; the credit charge is kept.reserve+release→ The generation failed; your credits were fully refunded.
Checking Your Balance
You can retrieve your current credit balance at any time viaGET /wallet/balance:
balance field is returned as a string to preserve decimal precision. Parse it with your language’s decimal or arbitrary-precision numeric type if you need to do arithmetic.
Related
Wallet Balance
Retrieve your current prepaid credit balance via the API.