BurnGuard calculates the cost of every OpenAI API call by multiplying the token counts returned in the response’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Verifieddanny/BurnGuard/llms.txt
Use this file to discover all available pages before exploring further.
usage field against built-in pricing tables. No sampling or estimation is involved — every request is accounted for at its actual token cost. Pricing tables are compiled into the BurnGuard binary and updated with each release.
Model Pricing Table
The table below lists the per-1M-token rates encoded inanalyzer.go. BurnGuard matches the model string returned by the API and selects the corresponding rate; any unrecognised model falls through to the fallback rate.
| Model | Input ($/1M tokens) | Output ($/1M tokens) |
|---|---|---|
gpt-4o, gpt-4o-2024-11-20, gpt-4o-2024-08-06, gpt-4o-2024-05-13 | $2.50 | $10.00 |
gpt-4o-mini, gpt-4o-mini-2024-07-18 | $0.15 | $0.60 |
gpt-4.1 | $2.00 | $8.00 |
gpt-4.1-mini | $0.40 | $1.60 |
gpt-4.1-nano | $0.10 | $0.40 |
o3, o3-2025-04-16 | $2.00 | $8.00 |
o3-mini, o3-mini-2025-01-31 | $1.10 | $4.40 |
o4-mini, o4-mini-2025-04-16 | $1.10 | $4.40 |
o1, o1-2024-12-17 | $15.00 | $60.00 |
gpt-5 | $1.25 | $10.00 |
gpt-5-mini | $0.25 | $2.00 |
gpt-5-nano | $0.05 | $0.40 |
| All other models (fallback) | $2.00 | $8.00 |
Cached Prompt Token Discount
OpenAI’s prompt caching feature reduces costs when the same prompt prefix is reused across requests. BurnGuard reads bothprompt_tokens and prompt_tokens_details.cached_tokens from the API response and splits the prompt cost into two buckets billed at different rates.
How the split works:
prompt_tokens— total tokens in the prompt (cached + uncached combined)prompt_tokens_details.cached_tokens— the subset that was served from OpenAI’s cacheuncached_tokens = prompt_tokens − cached_tokens
- Most models: cached tokens billed at 50% of the standard input rate
- gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, gpt-5.5, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna: cached tokens billed at 10% of the standard input rate
cache_discount is 0.50 for most models and 0.10 for gpt-5.4 and the listed gpt-5.5/5.6 variants.
Example calculation:
How BurnGuard Parses OpenAI Usage
BurnGuard extracts token counts through two code paths depending on whether the request uses standard HTTP responses or server-sent events (SSE) streaming. Non-streaming responsesExtractUsage() in parser.go JSON-unmarshals the full response body into an OpenAIResponse struct. The usage field maps to the following struct:
ParseSSE() in sse.go accumulates SSE data lines as the response streams through the proxy. It scans each line for a valid JSON chunk and looks for:
- The model name in the first chunk that carries a non-empty
modelfield - A final chunk where
usage.total_tokens > 0, which contains the completeprompt_tokensandcompletion_tokenscounts
Cached-token discounts are applied only for non-streaming responses. In the SSE path,
prompt_tokens_details.cached_tokens is not populated by the stream chunks BurnGuard reads, so all prompt tokens are billed at the full uncached rate.Pricing rates are compiled directly into the BurnGuard binary. If OpenAI updates their published prices, upgrade to the latest BurnGuard release to ensure your cost calculations reflect the new rates.
