Routing
Send each request to the model that should answer it — by priority, cost, latency, or a header your app sets. Change the rule without shipping your app.
# lattice.yaml
routes:
- match: { header: x-tier, equals: free }
models: [mistral-small, llama-3.1-8b]
- match: { default: true }
models: [gpt-4o, claude-sonnet, gemini-pro]
strategy: lowest-latency
Fallbacks
On a 429, a 5xx or a timeout, the same request moves to the next model in the route — streamed responses included. Your app sees one answer.
fallback:
on: [429, 500, 502, 503, 529, timeout]
timeout_ms: 8000
max_hops: 2
Cache
Exact and semantic caching at the gateway. Repeated prompts come back in single-digit milliseconds and cost nothing. Off by default for anything with a user id.
Keys & budgets
Virtual keys per team, service or customer, each with a monthly budget and a tokens-per-minute ceiling. Provider keys never leave the gateway.
Traces
Every request is a trace — route, hops, tokens, time to first token, cost — exported over OpenTelemetry.
Where it runs
Hosted in three regions, or one container in your own cloud. Same config either way.