Control the AI bill
Keep the AI bill in check, tenant by tenant.
Quotas are in tokens and euros, per tenant, with a soft cap that warns or routes to a cheaper model, then a hard cap. Usage per tenant reads in the console, and the prompt is never logged.
The path
- ExposeAn OpenAI-compatible surface in front of your providers and models
- BudgetTokens and euros per tenant, soft cap then hard cap
- RouteTo a cheaper model, or an internal one for a sensitive request
- ReportUsage per tenant in the console, audit without the prompt
Spending stops at the gateway, before the provider: an overrun becomes a clear answer, not a line on the bill.
Configuration
The ai-cost example, as it ships with Flexway v1.6.3.
# What inference costs, and what happens when a backend fails: prices declared per backend, a
# monthly budget in euros per tenant beside the token budget, a soft cap that warns and moves the
# call to a cheaper backend, and fallbacks tried in order before any byte reaches the client - never
# an external one for a sensitive request.
version: 1
auth:
issuers:
- name: customers
discovery: https://login.example.net/.well-known/openid-configuration
audience: api
tenant_claim: org
ai:
security:
- oidc: { scopes: [inference] }
sensitive_header: X-Sensitive
default_backend: eu-large
sensitive_backend: on-prem
backends:
eu-large:
url: https://api.provider.example/v1
api_key: "file:/etc/flexway/secrets/provider-key"
default_model: mistral-large
external: true
price: { input_per_mtok: 2.00, output_per_mtok: 6.00 } # euros per million tokens
fallback: [eu-small, on-prem] # in order, on connection failure, 5xx, timeout
eu-small:
url: https://api.provider.example/v1
api_key: "file:/etc/flexway/secrets/provider-key"
default_model: mistral-small
external: true
price: { input_per_mtok: 0.10, output_per_mtok: 0.30 }
fallback: [on-prem]
on-prem:
url: http://vllm.inference.svc:8000/v1
default_model: mistral-7b-instruct
price: { input_per_mtok: 0, output_per_mtok: 0 } # 0 is a price: internal
budget:
store: "${COUNTERS_URL}"
monthly_tokens: 40000000 # both budgets hold: the first reached decides
monthly_eur: 50 # per tenant, over the calendar month
soft: { at: 0.8, backend: eu-small } # past 80 %: Flexway-Budget: soft, moved to eu-small
overrides:
- { match: { tenant: acme }, monthly_eur: 500 }Features
What is delivered in the published release v1.6.3, and what is coming; a feature is never shown as delivered before its release.
| Feature | Status |
|---|---|
| OpenAI-compatible /v1/* surface | Delivered · v0.1.0 |
| Budget and rate per tenant | Delivered · v0.1.0 |
| Policy routing across providers and models | Delivered · v0.1.0 |
| Sensitive requests pinned, sovereignty and fallback by policy | Delivered · v0.1.0 |
| Metadata audit, never a prompt | Delivered · v0.1.0 |
| Backends by kind (OpenAI, relay, gRPC), local or upstream metering | Delivered · v1.5.0 |
| Semantic cache, per operation | Planned |
Going further
- Open this template in the editorYour architecture, its flexway.yaml and its simulated decisions, in the browser.
- Work out your AI budgetA thirty-day month for one tenant: the day of the soft cap, the day of the hard cap, and the ai.budget block written with your values.
- The guideStep by step, in the documentation of the published release
- AIToken and euro budgets, fallback, sovereignty
- OperationsOpenTelemetry, console, proposals as PRs
Let's talk about your gateway
Flexwiz is a young company: you talk directly with the person who founds it. Tell us what you want to run through Flexway. We talk about your infrastructure and your digital sovereignty requirements.
Online booking is coming soon; until then, an e-mail is enough.