An LLM application that starts a second model request before the first one finishes can pay for both attempts, even when the user sees one answer. Track each attempt under the same application operation and customer. Use the winning attempt to measure delivery latency and use all attempts to estimate inference spend. Keep provider-reported usage, estimates and unresolved usage distinct until you reconcile them.
A delayed duplicate is a hedge. Dean and Barroso describe hedged requests in The Tail at Scale: send a secondary request after a delay and cancel the remaining work once the chosen result arrives. The useful comparison for an AI feature is the change in client-visible tail latency against the additional cost of all the duplicate work. The original paper's results describe its own systems.
Record a row for every provider attempt
Create the attempt record when the application dispatches it. Include the logical operation ID, attempt ID, customer, feature, provider project, model, route, dispatch time and reason for dispatch. Update the row with the terminal outcome, the usage and its source. Capture the provider request ID when the response makes one available. Record which attempt the application selected in a separate field. Keep the customer's identity in your own ledger and use a stable internal identifier in telemetry.
| Outcome | Usage treatment | Outcome treatment |
|---|---|---|
| Primary supplies the answer | Use its final usage if present | One result delivered |
| Backup finishes second | Use its final usage if present | Completed attempt, result discarded |
| Primary is cancelled after dispatch | Use reported usage or mark it estimated or unresolved | Cancellation requested |
| Backup never dispatches | No provider attempt | Record that the hedge did not start if needed for analysis |
For OpenAI Chat Completions, streamed usage arrives in a final usage chunk when requested. An interrupted stream can lose that chunk. A local cancellation timestamp establishes when your caller stopped waiting. Keep it as operational evidence and keep any unknown token count unresolved. A partial response also omits any token categories that the endpoint reports only in its usage fields.
Calculate the cost of the latency improvement
Suppose a hypothetical feature serves 10,000 successful operations in each of two trial groups. At the same model mix and rates, the baseline group costs $40. The hedge group costs $40 for selected attempts, $5 for completed unselected attempts and an estimated $2 for cancelled attempts. Its cost per delivered result is about $0.0047, compared with $0.0040 in the baseline. That is an estimated 17.5% increase. If p99 time to usable output drops from 4.2 to 3.1 seconds, the trial buys 1.1 seconds at p99 for an additional estimated $7 per 10,000 results. These figures are illustrative.
Use comparable traffic and include failed operations in total spend. Report success rate beside the cost per delivered result. Measure time to usable output, after any checks required for that feature. Time to first byte may improve even when both attempts stall on generation or the first result fails validation.
Reconcile usage before expanding the trial
Compare attempt totals with provider billing by provider project and billing window. OpenAI's usage and cost guide distinguishes response usage from billed costs. If the provider supplies only aggregate costs, keep the unexplained difference at that level. A shared project can include unrelated traffic. Prorating the difference across customers may suit a documented internal allocation rule, but it gives you an allocation estimate. Keep the estimate visible and avoid presenting it as measured usage for a particular request.
Give the backup a separate admission decision and cap duplicate traffic during provider degradation. Otherwise a slow upstream can cause a burst of extra attempts precisely when capacity is scarce. Keep operations with external side effects outside this trial unless your application can guarantee a single committed action. Turn off hedging if the tail-latency gain disappears or unresolved spend exceeds the trial threshold.
Alectura's request limits reserve usage at admission and settle from provider usage when available. Its fallback usage estimate uses estimated input and the text the client received. Keep application-level operation IDs and compare the ledger with billed costs when evaluating your own parallel dispatch. The gateway latency measurement guide explains where to time the request path.
Source documents (2)
- The Tail at ScaleChecked
- OpenAI API usage and costsChecked
Trace a request through Alectura.
Bring a sample prompt and a customer policy. See what reaches the model and which decisions appear in the request record.