An LLM gateway sits between applications and model providers to handle routing, authentication, fallbacks, rate limits, and governance. Manuja says availability, latency, guardrails, and cost compete during degradation. Sequential per-request fallbacks can improve availability, while parallel requests reduce latency at the cost of doubling spend; provider cooldowns and shared failure counts are other options.
Productionizing LLM Gateways: Architecture, Tradeoffs and Hard Lessons
Speaker
Kanish Manuja, a principal engineer at Twilio, discusses production tradeoffs in LLM gateways at an AI Engineer talk.
Provider fallbacks can differ in tool schemas, token limits, and stop reasons, so they need testing and normalization. Streaming commits the request to its chosen provider because already-sent output cannot be moved elsewhere. For mixed workloads, Manuja recommends tracking P99 by model and route, setting route-specific timeouts, and giving fallback providers enough capacity to handle traffic.
Reasoning and router models can have highly variable response times; Manuja describes production P99 latency reaching 60 seconds. He recommends fixing reasoning levels per route and making requests as deterministic as possible. A second request can be launched when the primary has used around 90% of its latency budget to hedge the tail.
Guardrails for prompt injection, PII, and toxicity introduce their own reliability and latency tradeoffs. Teams should choose fail-open or fail-closed behavior based on the worst case they can accept, then set guardrail time budgets and consider backup checks or cached decisions. Guardrails can run before, alongside, or after model generation, with different effects on latency, streaming, and auditing.
Manuja recommends segregating API keys by route and use case, bounding queues, and preparing load shedding and traffic prioritization for retry storms. He warns that a company-wide central gateway can become a single point of failure. Centralized governance, such as cost tracking and rate limit management, can instead be implemented across decentralized gateway deployments.
Takeaways
- Use sequential provider fallbacks by default; parallel calls trade lower latency for higher cost.
- Test fallback providers and provision enough capacity for them to absorb failures.
- Measure P99 and set timeouts by model and route, especially for mixed workloads.
- Choose fail-open or fail-closed guardrail behavior based on the worst acceptable outcome.
- Centralize gateway governance while considering decentralized traffic deployments.
Mentioned in this talk
Search inside this talk
What was claimed 8
- works atKanish Manuja works at
Twilio
Principal Engineer“I'm a principal engineer at Twilio.”
YouTube Verified2 sources· Talk, Web· archived
- featureMCP: Routes requests and provides authentication, fallback, rate limits, and governance between apps and model providers
“An LLM gateway is an entry point or middleware between your apps and the model providers behind them.”
YouTube Unverified1 source· Talk
- featureprovider fallback: Parallel requests to two providers can reduce latency at double the cost
“fire requests to both providers in parallel”
YouTube Unverified1 source· Talk
- featureprovider fallback: Can try provider B in sequence after a request to provider A fails
“try model provider A and then, in sequence, try model provider B if your request to model provider A fails”
YouTube Unverified1 source· Talk
- featurestreaming: Provider cannot be changed mid-stream after output has been sent to the client
“You can’t change providers mid-stream.”
YouTube Unverified1 source· Talk
- metricreasoning models: The same prompt can take anywhere from 2 to 60 seconds
“the same prompt can take anywhere from two to 60 seconds”
YouTube Unverified1 source· Talk
- featureguardrails: Can run on input, in parallel, or as post-hooks for output monitoring and auditing
“You can have a pre-hook, where the guardrail runs on the input.”
YouTube Unverified1 source· Talk
- featuredecentralized gateway with centralized governance: Can centralize cost tracking and rate limit management without centralizing traffic
“Don’t try to centralize your traffic, but you can use plugins or custom code to centralize governance.”
YouTube Unverified1 source· Talk











