📌 Part of Blueprint: AI Agent & Local GPU Automation → L1: Deterministic Orchestration & State Machines

Reconciling an OpenAI Suspicious API Key Alert Against Usage and Cost Exports

· 5 min read · Notes openaiapi-keysbillingsecurityusage-exportincident-response

The Alert Is a Pointer

The email was short: one key name, one project, one source network and a last-used timestamp, with a 24-hour revocation window. It did not include a request count or a key-level cost. When I reconciled it against the exports, the account showed 1,086 requests and USD 8.98 for the day, while the invoice was USD 5.40 — three different scopes.

That is enough to start a rotation. It is not enough to answer the questions that follow: how many requests used the key, what did they cost, and was the invoice caused by the same activity?

The alert deliberately discloses less than the console. It shows a key name, not the secret. It shows the originating network, not the request list. It shows last used, not the first use or the count between them. Treating the email as the incident record produces a report with more confidence than evidence.

I put rotation first: create a replacement key, update the applications that need it, then revoke the old key. Attribution can wait; a live key continues to spend while the investigation is being assembled.

Four Gaps Between the Alert and the Ledger

The alert has no request count. A last used timestamp is a timestamp, not a volume. A key used once and a key used a thousand times produce the same line. The count has to come from the usage export.

The account total is not the key total. The usage CSV for the incident day contained 1,086 requests across five keys. Filtering to the key named in the alert left 108 requests across 22 models, with 58,204 input tokens and 7,579 output tokens. The other 978 requests belonged to other keys. Reporting the account total as the compromised key’s usage would overstate the incident by an order of magnitude.

The daily cost is not a per-key cost. The cost export showed USD 8.98 for the incident day and USD 0.0025 for the previous day. That is a real anomaly and a useful signal, but it is an account-level number. The export did not allocate the full day to the affected key. The correct statement is: the day’s spend rose from USD 0.0025 to USD 8.98; the affected key’s share was not established from this export.

The invoice is a payment event. The invoice on the account was USD 5.40: USD 5.00 for an API usage credit auto-reload plus USD 0.40 service tax. It was not a bill for the flagged key’s requests. Attaching it as proof of loss would confuse a top-up with consumption. It belongs in the billing folder, not in the evidence pack.

The Export That Answers the Question

The useful artifact is the usage export with the key identifier intact. The console’s daily aggregate is not enough; the CSV I used had api_key_id, start_time_iso, model, num_model_requests, input_tokens and output_tokens.

I ran a five-step reconciliation:

  1. Export the incident day and the day before.
  2. Filter to the key named in the alert.
  3. Count requests and tokens per model.
  4. Sum the account cost separately, without attributing it to the key.
  5. Keep the invoice in a separate file.

The result for this incident:

MetricValue
Affected key’s requests108
Models used by that key22
Input tokens58,204
Output tokens7,579
Account requests on the day (2026-12-03)1,086
Account total cost on the day (2026-12-03)USD 8.98
Account total cost the day before (2026-12-02)USD 0.0025
Invoice totalUSD 5.40
Invoice compositionUSD 5.00 auto-reload + USD 0.40 tax

The model list was the second review input. The flagged key called 22 model names; the export alone does not prove misuse, but the list is worth comparing with the application’s configured model set.

The export also showed the limit of the redacted version. Removing api_key_id makes the CSV safer to share and makes per-key attribution impossible. I keep two copies: an internal export with the identifier, and a shared one with the identifier removed and a note that the day total is account-wide, not key-specific.

What to Change After the Rotation

The alert is a symptom of key handling, not a billing bug. Four changes would reduce the next incident:

The alert’s 24-hour window is real. Rotation is the only action that stops the spend; the export, the report and the vendor case can follow. The reverse order leaves a live credential in place while the investigation looks for a number the email never contained.

The Result

The alert named one key and one source network. The usage export turned that into 108 requests, 22 models, 58,204 input tokens and 7,579 output tokens. The account total was USD 8.98 for the day, against USD 0.0025 the day before. The invoice was USD 5.40, of which USD 5.00 was an auto-reload and USD 0.40 was tax.

Those are four different scopes: key usage, account usage, daily spend and payment. Keeping them separate is the difference between an incident report and a number that looks alarming but cannot be defended.

💼 Work With Me

Looking for high-impact engineering work or custom systems?

From front-end web apps down to edge proxies and container automation. Open to serious freelance client projects and senior engineering roles.

Lee Teong Hoe

Lee Teong Hoe · Mr Hoelee

Full-stack developer & DevOps engineer based in Malaysia. I run my own production infrastructure and build web systems for small businesses — this blog is the living record.

Hiring? Profile & stack · Malaysian SME? Website design & development ↗ · All posts