Skip to main content

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.

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.

Prerequisites

  • BurnGuard installed and the proxy running (burnguard start)
  • A burnguard.yaml in your project directory (run burnguard init to generate one)
  • An OpenAI API key already working in your application

Configure OpenAI in burnguard.yaml

The providers.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.
providers:
  openai:
    base_url: https://api.openai.com

Update Your App

Change the base URL your SDK or HTTP client uses to point at BurnGuard. That is the only required change.
# Before
from openai import OpenAI

client = OpenAI()

# After — one line changed
from openai import OpenAI

client = OpenAI(base_url="http://localhost:8080/openai/v1")
Your 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.
ModelInput / 1M tokensOutput / 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
Pricing is compiled into the binary and updated with each BurnGuard release. Unrecognized model identifiers fall back to the 2.00/2.00 / 8.00 rate rather than being silently skipped.
Use gpt-4.1-nano (0.10/1Minput)orgpt4omini(0.10 / 1M input) or `gpt-4o-mini` (0.15 / 1M input) during development and automated testing. Both are capable enough for most functional tests and will consume a fraction of your budget compared to gpt-4o or o1.

Cache Discount

OpenAI automatically caches repeated prompt prefixes and bills them at a reduced rate. BurnGuard reads prompt_tokens_details.cached_tokens from every response and applies the correct discount when calculating cost.
ModelCached 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-luna10% of standard input rate
All other models (gpt-4o, gpt-4.1, o3, o4-mini, gpt-5, etc.)50% of standard input rate
For example, with gpt-4o (input rate $2.50 / 1M):
  • 1,000 standard (uncached) prompt tokens → $0.0025
  • 1,000 cached prompt tokens → $0.00125 (50% rate)
The blended cost across cached and uncached tokens is what gets added to your running budget total and displayed in your dashboard.

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.

Build docs developers (and LLMs) love