This guide shows you how to route your existing OpenAI SDK or HTTP client through BurnGuard so that every GPT request is metered, costed in real time, and checked against your budget cap — requiring only a single line change in your application code.Documentation 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.
Prerequisites
- BurnGuard installed and the proxy running (
burnguard start) - A
burnguard.yamlin your project directory (runburnguard initto generate one) - An OpenAI API key already working in your application
Configure OpenAI in burnguard.yaml
Theproviders.openai.base_url field tells BurnGuard where to forward requests after stripping the /openai path prefix. The default value is correct for the public OpenAI API and does not need to change unless you are using the Azure OpenAI Service or another compatible endpoint.
Update Your App
Change the base URL your SDK or HTTP client uses to point at BurnGuard. That is the only required change.- Python
- TypeScript
- cURL
OPENAI_API_KEY environment variable is forwarded to OpenAI unchanged. BurnGuard never stores or logs API keys.The OpenAI base URL includes
/v1, while the Anthropic base URL does not.
This matches each SDK’s expectation: the OpenAI SDK appends endpoint paths
like /chat/completions directly to baseURL, so baseURL must end with
/v1. The Anthropic SDK always appends /v1/messages itself, so baseURL
should stop at /anthropic. When in doubt, check the path your SDK
constructs — it should reach BurnGuard as /openai/v1/chat/completions or
/anthropic/v1/messages.Supported OpenAI Models
BurnGuard uses the pricing table below to calculate the cost of every request. Costs are in USD per one million tokens.| 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 | $2.00 | $8.00 |
Cache Discount
OpenAI automatically caches repeated prompt prefixes and bills them at a reduced rate. BurnGuard readsprompt_tokens_details.cached_tokens from every response and applies the correct discount when calculating cost.
| Model | Cached token 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 | 10% of standard input rate |
| All other models (gpt-4o, gpt-4.1, o3, o4-mini, gpt-5, etc.) | 50% of standard input rate |
gpt-4o (input rate $2.50 / 1M):
- 1,000 standard (uncached) prompt tokens → $0.0025
- 1,000 cached prompt tokens → $0.00125 (50% rate)
SSE Streaming Support
BurnGuard fully supports OpenAI’s streaming API ("stream": true). When a response arrives with Content-Type: text/event-stream, BurnGuard wraps the response body in a streaming reader that reads each SSE event as it passes through and extracts token counts from the usage field in the final [DONE] event — all without buffering the stream or adding latency.
The OpenAI SDK’s .stream() helper and raw streaming both work transparently through the proxy. No additional configuration is needed.