A retry can repeat network delivery, provider execution, or both. Usage accounting must distinguish those cases or the product can double-count customer consumption, undercount provider cost, or do both at once.
Give the user's logical operation a stable identity and record execution attempts separately. Then define how actual provider work becomes the customer-facing usage ledger under the product's policy.
Separate three kinds of records
The logical operation describes the requested task. Attempt records describe retries and their outcomes. Usage entries describe reserved, settled, released, or adjusted consumption. Linking them makes it possible to explain a total without assuming every attempt represents a new purchase.
Provider-side idempotency or usage-reporting features vary. Check the current official documentation for the service used before relying on a retry guarantee. This article proposes the accounting model and tests, not an unverified claim about a particular AI API.
Test a fictional document-review retry
Suppose a user requests one document review. The provider completes processing, but the application loses the response before showing it. The browser retries. In one design the retry retrieves the existing result; in another it triggers another provider execution.
Record both the logical operation and attempts so support can distinguish them. The customer policy might charge once for the logical task while internal cost records reflect two executions. That is a deliberate commercial decision, not evidence that only one provider charge occurred.
Test failure before dispatch, timeout during execution, confirmed provider completion with lost delivery, duplicate completion notification, and concurrent retries. Verify reservations, final ledger entries, displayed balance, and internal provider-cost records.
Make settlement recoverable
If usage is settled after the result is delivered, a crash can leave completed work uncounted. If it is settled before execution, a crash can consume allowance without work. Use a durable lifecycle and reconciliation appropriate to the architecture.
Keep adjustments explicit. A support credit should reference the affected operation and reason rather than rewriting the original history. Period boundaries need a policy too: decide which period owns work requested before midnight but completed afterward.
The tradeoff is accounting precision versus implementation effort. A simple request counter may fit a low-cost prototype but becomes misleading when input size, retries, and provider work vary. Add detail where it changes customer fairness or operating decisions.
The product portfolio supplies related engineering context. This retry scenario is fictional and makes no claim about measured provider costs or a deployed billing ledger.
Questions about retry usage
Should every attempt count against the customer?
Only if that matches the explicit policy. Internal provider cost and customer billing can legitimately differ, but both should remain explainable.
Can a single request ID solve all duplicates?
It helps identify the logical task, but settlement, concurrency, and external side effects still need a consistency design.
What should be tested first?
Lose confirmation after provider completion, retry concurrently, and compare the operation, attempts, ledger, and visible balance. Bring discrepancies to a usage-accounting review.