LLM API Billing Audit: How to Investigate Unexpected Charges
This article explains how to audit LLM API charges when a provider's bill shows only summary totals. Using a case study of one user's local billing records from a premium platform subscription over nine days, it covers three common anomalies: KV cache misses billed at full price, requests routed to a different model than the one selected, and empty-response calls that still consume quota. It also outlines a three-layer automated audit approach, along with a checklist and guidance on handling disputes. The case figures come from a single user, so they are a sample rather than industry-wide conclusions.
Introduction
Pay-as-you-go and monthly subscription billing have become the mainstream models for large language models. Inference, however, involves context management, KV caching, and multi-model routing, while bills usually show only summary totals. Without a breakdown, it is hard to see where each charge came from, and provider reports alone make it difficult to judge whether costs are reasonable. This article draws on a case in which a developer audited local billing records for a premium platform subscription. It discusses common anomalies and outlines an executable approach to automated auditing.
The figures in this case come from a single user, a single platform, and a specific time period. Treat them as a sample, not as industry conclusions. Findings should be verified against the provider’s server logs and your own application’s call records.
1. Where the Audit Data Comes From and Its Limitations
After noticing a drop in response quality and faster-than-expected quota consumption, the user decided to check the billing data that the client application stored locally. The user exported about 23,000 billing records covering nine days from a local SQLite database. The records were serialized in Protocol Buffers format, so each field had to be deserialized before the data could be read.
This method bypasses the provider’s aggregated billing views and shows a record for each request. It has several prerequisites:
- Read only the local billing data generated by your own account. Do not access login credentials, passwords, or other sensitive information.
- Confirm how tokens are counted, including how input, output, and cache-hit tokens are each counted.
- Record the platform version, time range, and sample size so others can reproduce the review.
- Read the data on your own machine, and anonymize it before sharing.
2. Three Typical Anomalies
1. KV cache misses billed at full price
A KV cache stores precomputed key-value pairs for the context. In a continuous conversation, the model can avoid recomputing that context, and billing usually offers a discount for cached tokens. In this case, the auditor found that about 49.5 million tokens were billed at the full uncached rate. Some records show cache hits dropping to zero even though two turns were less than 25 seconds apart and the context had not been compressed or truncated.
This pattern deserves attention, but it does not by itself prove a platform defect. Cache misses can result from the following:
- The session was switched, or the request prefix changed.
- The server-side cache expired or was evicted, or the request was routed to a different inference instance.
- The client or request parameters disabled caching.
- The provider’s caching implementation or routing policy differs from what you expect.
To verify, compare consecutive requests in the same session that share the same prefix, and ask the provider for server-side logs showing cache hits. In this case, other models in the same environment kept stable cache hit rates across hundreds of consecutive conversations. That comparison suggests the problem may relate to the specific platform or its routing, but more samples are needed to confirm it.
2. Actual routed model differs from the model selected
In this case, the user selected a high-tier reasoning model, but the underlying data showed that some requests were handled by a downgraded version. After a certain point in time, the average number of output tokens fell from the 1,600 to 2,600 range to the 300 to 600 range, a noticeable decline. Thousands of requests labeled as “orchestration” were also routed to a lightweight model that is not publicly disclosed.
A drop in output length can have several explanations, such as a change in task type, a change in system prompts, or a model version update. To determine whether a downgrade occurred, review routing records, model identifiers, and the output length distribution together. Use the provider’s commitments in its service level agreement (SLA) as the reference point.
3. More zero-thinking calls, and empty responses still billed
In agent or complex reasoning tasks, the model sometimes returns a result without deep reasoning. The case study calls these “zero-thinking calls.” Their share rose from 0.3% to 64.9% within a few days. Interpreting this change requires considering the task type. It cannot serve as evidence of a capability decline on its own.
Billing requires treating input and output tokens separately. Once a request is sent, its input tokens are usually already processed, so the provider may bill for input even when the output is empty. Therefore, the rule that empty responses are not billed does not apply to every platform. In this case, some requests returned no valid result, yet quota kept being deducted until the requests triggered 429 rate-limit errors. In such cases, record and verify the incidents, and include the request ID, timestamp, and response status when filing an appeal.
3. Appeals and Dispute Handling
After the user appealed to the platform and asked for a refund, customer support said a refund would also cancel the entire membership and reclaim the cloud storage benefits bundled with the AI service. This bundling made the dispute harder to pursue. Before purchasing, confirm whether each benefit can be handled separately, and keep written records of the refund terms and the benefit terms.
4. Designing an Automated Audit
An audit script can be organized into three layers: data extraction, rule validation, and anomaly summarization.
- Data extraction layer: Read the locally stored billing logs, parse the serialized fields, and output records in a unified structure.
- Rule validation layer: Check each record against the rules and flag anomalies.
- Anomaly summary layer: Count anomalies by type, share, and time distribution, then generate a report.
The table below lists the key fields and conditions for each layer.
| Layer | Fields or Conditions | Description |
|---|---|---|
| Data extraction | record_id, timestamp (seconds), session_id, context_length, cache_hit_tokens, input_tokens, output_tokens, billed_tokens, requested_model, routed_model | Field names are examples and should be adjusted to the actual schema |
| Cache rule | Within the same session_id, the interval between two consecutive requests is less than 60 seconds, context_length does not decrease, and cache_hit_tokens is 0. Flag as “to verify.” | The threshold is configurable, with a default of 60 seconds. Confirm that the provider supports caching. |
| Routing rule | requested_model differs from routed_model. Flag as “to verify.” | Exclude legitimate orchestration allowed by the provider. |
| Billing rule | output_tokens is 0 and billed_tokens is greater than 0. Flag as “to verify.” | Account for the input billing portion before judging. Follow the provider’s documentation for input billing rules. |
| Summary alert | Count occurrences, shares, and time periods by type | Trigger an alert when the anomaly share exceeds a set threshold |
The example assumes the SQLite table is named billing_records and that the protobuf schema is provided by the provider’s client package.
CACHE_WINDOW_SECONDS = 60def audit_billing_logs(log_file_path):records = deserialize_logs(log_file_path) # Depends on the protobuf schema for the matching versionrecords.sort(key=lambda r: (r.session_id, r.timestamp))anomalies = []for prev, curr in zip(records, records[1:]):if prev.session_id != curr.session_id:continuegap = curr.timestamp - prev.timestampif (gap < CACHE_WINDOW_SECONDSand curr.context_length >= prev.context_lengthand curr.cache_hit_tokens == 0):anomalies.append({"type": "CacheMissToVerify", "record_id": curr.record_id})if curr.output_tokens == 0 and curr.billed_tokens > 0:anomalies.append({"type": "EmptyResponseBillingToVerify", "record_id": curr.record_id})if curr.requested_model != curr.routed_model:anomalies.append({"type": "RoutingMismatchToVerify", "record_id": curr.record_id})return generate_report(anomalies)
Every anomaly the script outputs should be marked as flagged for verification. None of them should be treated as a confirmed billing error. Session switches, client retries, and legitimate orchestration routing can all cause false positives. Keep the original records, make each audit’s output reproducible, and compare the results with the provider’s server-side logs.
5. Audit Checklist and Prevention Tips
Audit LLM billing in the following order:
- Confirm how billing counts usage, and distinguish input tokens, output tokens, and cache-hit tokens.
- Record the request ID, session ID, model identifier, and timestamp for each call.
- Compare cache hit rates across consecutive requests in the same session.
- Check whether the actual routed model matches the selected model.
- Count empty responses and 429 errors, and compare them with the billing records.
- Submit the findings to the provider for verification, and keep the evidence.
Enterprises and developers should not rely only on the provider’s bill. Set up independent call logs and billing monitoring from the integration stage, and reconcile business usage against the provider’s charges. If your cloud provider offers logging and monitoring services, you can include API call chains in unified tracing. This lowers the cost of investigating problems after the fact.
How to Appeal Charges for Empty Responses
Prepare the request time, request ID, response status code, and billing records. Submit them through the provider’s dispute process, and ask for a written response.
