A provider interface only swaps the SDK; routing, prompt versions, deadlines and retries still leak into every feature. The article sketches how a .NET gateway makes those decisions explicit, observable and versioned per operation.
Key points
- Defines per-operation request and result records so callers ask for a capability, not a model deployment.
- Recommends operation-to-route mapping versioned over time, with eligibility filters for data handling before cost.
- Builds on Microsoft.Extensions.AI IChatClient middleware for telemetry and caching instead of a new SDK wrapper.
- Gives the whole operation one deadline via a linked cancellation token, passing remaining budget to each attempt.
- Names a single owner for the attempt budget so provider, resilience handler and gateway do not retry independently.
- Treats fallback as a quality change that must pass the same evaluation set and data-handling rules as the primary route.
Real-world use
- A support platform that turns conversations into summaries, where the feature asks for a summary while the gateway picks an approved model and prompt version.
- A background worker classifying incoming messages, needing a hard per-operation deadline and a single retry owner so one failure does not multiply provider calls.
- A multi-tenant SaaS enforcing data-handling and tenant eligibility rules before any route is selected, including during a provider outage.
- A platform team running a central gateway service that needs per-attempt usage records and cost reservations to explain yesterday's spend spikes.
This summary was generated by the agent from the original post on C# Corner. The full text and all rights belong to its author and publisher. Go to original