Problem 1
The inference bill runs away
A tenant or an agent loop consumes without limit; the bill arrives at month end.
Flexway's answer: Monthly budget in tokens and euros per tenant; a soft cap that warns and moves to a cheaper model.
AI
An OpenAI-compatible API in front of your providers and internal models: token and euro budgets per tenant, ordered fallback before the first byte, and never an external model for a sensitive request.
11 of the 13 shown delivered · since v0.1.0
What you expect from this domain


Problem 1
A tenant or an agent loop consumes without limit; the bill arrives at month end.
Flexway's answer: Monthly budget in tokens and euros per tenant; a soft cap that warns and moves to a cheaper model.
Problem 2
A request with personal data goes to a model hosted outside your walls.
Flexway's answer: A request marked sensitive is pinned to an internal model, or refused.
Problem 3
The main model errors or times out; the application fails.
Flexway's answer: Fallbacks tried in order before any byte to the client, a circuit breaker per model.
Every step is a decision readable in the trace and in the console.
AI - Domain diagram: who calls, the decision steps, what is called, and where a request is refused.
budget exhausted: 429
The applications that call your APIs: each request goes through Flexway, which checks the contract and the identity before reaching your systems.
Routes through here
AI agents: they call MCP tools and models through Flexway, under the same identity, quota and audit as an API.
Routes through here
Flexway checks who is calling (OIDC token, API key or client certificate) and reads the tenant from the identity; no valid identity: 401.
Routes through here
A request marked sensitive goes only to an internal model, never to an external provider.
Routes through here
Flexway picks the model by policy: default backend, declared override or soft cap depending on the request.
Routes through here
The tenant's budget, in tokens and euros, is reserved before the model call; exhausted: 429 budget_exceeded.
Routes through here
If the model fails (outage, 5xx, timeout), Flexway moves to the next one before any byte is sent back and says so in the response.
Routes through here
The model's response is relayed without buffering, streams included, and the budget is reconciled at the real price of the model that served.
Routes through here
A model provider outside your infrastructure: called under budget, never for a sensitive request.
Routes through here
The cheaper fallback model: Flexway falls back to it if the first one fails, before any byte is sent back.
Routes through here
A model running on your premises: sensitive requests never leave your infrastructure.
Routes through here
The essentials of each topic, with its status in the published release; unfold a card for the full text.
The gateway serves an OpenAI-compatible /v1/* with no contract to write, under the same identity and policies, towards backends declared by kind.
The gateway serves /v1/* with no contract to write: the built-in operations ai.chatCompletions, ai.listModels and ai.embeddings answer under the ai section of flexway.yaml, with the same identity, policies and tracing as the rest of the traffic. Errors on /v1/* are returned in the OpenAI error envelope, gateway refusals included, and as RFC 9457 everywhere else. Streaming is relayed line by line, unbuffered, and the budget is reconciled on the final usage.
A backend is declared by its kind: openai for any OpenAI-compatible API (the default), relay for another Flexway, grpc for the upstream of a specialised model. No provider is named in the product: a backend is a URL, an authentication method and a price. Authentication is generic - none, bearer by reference, header with a declared name, token_file re-read on every call as a workload identity projects it - and client TLS can be added for an mTLS relay.
The requested model is served if it appears in the backend's models list, otherwise its default_model is used; the audit keeps the model actually served. Earlier configurations load unchanged.
Flexway counts tokens and euros per tenant, switches to a cheaper backend at the soft cap and refuses with 429 at the hard cap.
A requests-per-second quota says nothing about the cost of a model call. Flexway counts tokens per day and per month, and euros per month, per tenant: each backend declares its price (euros per million input and output tokens), and the first budget reached decides. Each call is pre-reserved, then reconciled at the price of the backend that actually served it.
At the soft cap (ai.budget.soft), the response carries the Flexway-Budget: soft header and traffic switches to the declared, cheaper backend; at the hard cap, the request is refused with 429 budget_exceeded. A failed or refused call gives its reservation back, tokens and euros: a failing backend does not drain a tenant's budget. Overrides per tenant and per agent set a different backend and different budgets.
Behind a relay to another Flexway that meters on its own (metering: upstream), the local cap still applies, the upstream's 429 is relayed as is and series carry metered_by="upstream", so that consumption is counted once, where it is paid. flexway validate warns about a relay metered locally, which would count twice.
A request marked sensitive goes only to an internal backend, otherwise it is refused: the header narrows routing, never widens it.
A request flagged as sensitive by the declared header (ai.sensitive_header) is pinned to the designated internal backend (ai.sensitive_backend). That backend must be internal: declaring an external one is refused at load. If no internal backend can serve it, the request is refused rather than sent outside. The header can only narrow routing, never widen it.
A relay to another Flexway is treated as external unless declared otherwise (external: false): only the operator decides that another gateway may receive sensitive traffic. The call's identity is passed under declared names only (identity_headers: tenant, agent, sensitive); nothing from the caller's request is copied. Neither the soft-cap switch nor fallbacks ever send a sensitive request to an external backend.
Backend choice is declarative: default, then tenant and agent override, then capability override, then sensitivity; neither latency, nor content, nor the requested model decides. Declaring which backend serves which tenants helps you meet your data residency requirements; automatic routing by latency or by jurisdiction is upcoming.
On a failure, 5xx or timeout, the declared fallbacks are tried in order before any byte is sent, never on a 4xx nor towards an external backend when sensitive.
Each backend declares a fallback list, tried in order on connection error, 5xx, timeout or open circuit. Fallback happens before any byte reaches the client, each backend once. It never happens on a 4xx, a provider's 429 included, and never to an external backend for a sensitive request. A response served by a fallback carries Flexway-Degraded: backend-fallback.
A circuit breaker per backend avoids insisting on a model that has stopped answering. Fallback applies to the openai and relay kinds and keeps only backends that serve the requested capability: a request with an image falls back only to a vision backend. Fallback on an exhausted budget is the soft cap described above.
Inference-aware routing - by model, request criticality, actual model-server load or context-cache affinity, interfacing with the Gateway API Inference Extension on Kubernetes - is upcoming. The semantic cache, opt-in per operation, is upcoming as well.
Every inference call leaves a metadata audit line - tenant, model, tokens, cost - without ever collecting the prompt or the response.
Each inference call produces a metadata audit line: tenant, agent, served model, backend, tokens, cost. Prompts and responses are never collected, and identifiers are hashed in logs. Per-tenant reporting, for internal billing or chargeback, comes out of this audit with no extra tooling.
The same facts feed the flexway.inference.cost and flexway.inference.calls metrics, with metered_by and capability dimensions, which the console reads for its per-tenant and per-backend gauges. Keeping a usable record of who called which model at what cost, without keeping the content, helps you meet the logging and data governance requirements that apply to AI usage.
Images, embeddings and specialised gRPC models are metered against the tenant's budget, each served by a backend with the requested capability.
Message content can be a string or text and image_url parts, in the OpenAI format. The image is measured in the body without being decoded (ai.vision.max_image_bytes, 8 MiB by default; body bounded by ai.vision.max_body_bytes, 24 MiB by default); data: URIs are accepted by default, a remote URL only from a declared https origin (ai.vision.allowed_origins), and any other part type is refused. An image goes only to a backend with the vision capability, otherwise 400 capability_unavailable; it is pre-reserved at 2,048 tokens, reconciled on the reported usage.
POST /v1/embeddings follows the same path as a completion: identity, budget on prompt_tokens, fallback before any byte, metadata audit, and a backend with the embeddings capability. A gRPC method of a specialised model is metered when it carries the ai option of (flexway.v1.operation), the gRPC counterpart of x-flexway-ai: per call (body never read) or per byte, with a price per thousand and a feature.
For these models, the tenant's euro budget is reserved before the call and returned if the upstream did not serve; refusals are RESOURCE_EXHAUSTED budget_exceeded and PERMISSION_DENIED sensitive_no_internal_backend. Their upstream must be named by a kind: grpc backend, otherwise the configuration is refused at load.
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 }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 |
| Policy routing across providers and models | Delivered · v0.1.0 |
| Budget and rate per tenant | 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 |
| Inference streaming relayed without holding | Delivered · v0.1.0 |
| OpenAI-compatible multimodal content, vision backend | Delivered · v1.5.0 |
| Embeddings, with budget and audit | Delivered · v1.5.0 |
| Backends by kind (OpenAI, relay, gRPC), local or upstream metering | Delivered · v1.5.0 |
| gRPC method of a specialised model, metered per call | Delivered · v1.5.0 |
| Inference-aware routing (Gateway API Inference Extension) | Planned |
| Semantic cache, per operation | Planned |
| Usage: requests, tokens, euros, per tenant | Delivered · v0.1.0 |
Every feature · Work out your AI budget
The other expectations of this domain
chat, vision, embeddings); model aliases and use cases framed; routes per declared task are missingPartly · next in 1.9external attribute of backends and pinning of sensitive requests; the declared hosting class (cloud, private, local) is missingPartly · next in 1.9arm64 binary routes to a local model; running the model stays with the inference runtimePartly · next to be scheduledFlexwiz 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.