pub struct LlmCfg {Show 14 fields
pub enabled: bool,
pub api_style: String,
pub models: BTreeMap<String, ModelPrice>,
pub on_unpriced_model: String,
pub budgets: Vec<BudgetCfg>,
pub store: String,
pub redis_url: String,
pub redis_prefix: String,
pub fail_open: bool,
pub default_max_tokens: u64,
pub team_header: String,
pub keys: Vec<KeyEntryCfg>,
pub dlp: DlpCfg,
pub telemetry: TelemetryCfg,
}Expand description
LLM token-metering settings ([llm]). When enabled, the proxy parses OpenAI-compatible
request/response bodies to count tokens (from the upstream’s usage object) and, for any model
listed in [llm.models], the cost. Metering is observe-only: it never blocks or alters traffic.
An unmapped model still has its tokens counted (cost is simply omitted).
Fields§
§enabled: boolTurn on the LLM gateway: token metering, cost attribution, budgets, the key vault and DLP. Off by default, and irrelevant unless the upstream is an LLM API.
api_style: StringWire format. Only "openai" is understood today (the default).
models: BTreeMap<String, ModelPrice>Per-model price book, keyed by the model string clients send. Prices are USD per
1,000,000 tokens. Example:
[llm.models."gpt-4o"] input_per_1m = 2.5 / output_per_1m = 10.0.
on_unpriced_model: StringWhat to do with a request whose model is not in [llm.models]: "count" (default —
meter tokens, omit cost, forward the request) or "block" (reject 402 before it reaches the
upstream, so an unpriced model is never served at a silent $0). "block" only bites when a
price book is configured — a metering-only deployment (empty [llm.models]) never rejects.
budgets: Vec<BudgetCfg>Hard token/cost budgets (gateway L1). Empty by default (no enforcement — L0 metering only).
Each [[llm.budgets]] is a ceiling enforced fail-closed via reserve→reconcile. See BudgetCfg.
store: StringBudget store backend: "memory" (single replica / default) or "redis" (shared across
replicas — required for a true fleet-wide cap). "local" is treated as "memory".
redis_url: StringRedis URL when store = "redis", e.g. redis://127.0.0.1:6379. Note: EDGEGUARD_REDIS_URL
only overrides ratelimit.redis_url, not this key — set it here (or via pushed policy).
redis_prefix: StringKey prefix for budget keys in Redis (namespacing a shared server). Defaults to edgeguard.
fail_open: boolOn a budget-store error, allow the request (true) or reject it 503 (false, the default
— fail-closed, so an outage can’t silently uncap spend).
default_max_tokens: u64Completion tokens to assume when a request omits max_tokens, used only for the reserve
estimate (the reservation is reconciled to actual usage afterward). Default 1024.
team_header: StringRequest header carrying the team / tag a request is attributed to, for the per-team budget
scope and team chargeback. Case-insensitive; default x-edgeguard-team. A request without it
falls into the shared _none team bucket.
keys: Vec<KeyEntryCfg>BYO-key vault + egress governance (gateway L2). Empty by default (no vault). Each
[[llm.keys]] maps a client-facing virtual key to a real provider key (injected
upstream, never returned to the client) plus an optional per-key model egress allowlist.
When any key is configured, every proxied request must present a known virtual key. See
KeyEntryCfg.
dlp: DlpCfgEdge DLP — PII / secret detection + redaction (gateway L3). Off by default. See DlpCfg.
telemetry: TelemetryCfgOTLP span emission (gateway L4) — SDK-free tracing to an OTel-native store. Off by default.
See TelemetryCfg.