Skip to main content
This guide shows how to deduct credits for an operation directly, without mapping it to a metered feature, using the check, act, track pattern. Use it when you calculate the cost of an operation yourself. It works with or without an active subscription. The examples use the Node.js SDK. The same operations are available in every backend SDK and in the REST API.
1

Check the credit entitlement

Pass the expected cost as requestedUsage. hasAccess is true when the remaining balance covers it, or when the currency has a soft limit.
2

Deduct credits

Run the operation and calculate the number of credits it consumed, then deduct them. Use consumeCredits for strict, real-time enforcement (when synchronous credit consumption is enabled, the response includes the optimistic balance in credit), or consumeCreditsAsync for high-volume, eventually consistent consumption.