Microsoft.Extensions.AI has introduced new experimental primitives designed to manage routing and failover for AI models and providers. These additions aim to improve cost efficiency, application uptime, and reduce latency in AI-powered applications.
The new primitives allow developers to implement strategies for directing requests to different AI models or providers based on specific criteria, and to handle situations where a provider becomes unavailable.
Four new experimental types are available: RoutingChatClient, SemanticRoutingChatClient, FailoverChatClient, and OrderedFailoverChatClient. These types function as IChatClient implementations, providing a structured way to integrate routing and failover logic.
RoutingChatClient serves as the base class for selecting and forwarding requests to other clients. SemanticRoutingChatClient routes requests by message content, using embedding similarity against example utterances. FailoverChatClient adds a retry loop for reselecting clients upon failure, and OrderedFailoverChatClient is a concrete implementation that processes a list of clients sequentially.
The RoutingChatClient abstract class calls SelectClientAsync on each request to determine the target client. Developers can use RoutingChatClient.Create with a callback for simple routing or derive from RoutingChatClient to override SelectClientAsync for more complex, stateful policies.
Each call to GetResponseAsync or GetStreamingResponseAsync generates a RoutingContext, which includes request messages and a clone of ChatOptions. This design separates request-level options, which persist across retries, from route-level options, which are applied by client wrappers.
The SemanticRoutingChatClient enables routing based on the meaning of messages. This is achieved by comparing the embedding of the last user message against a set of example utterances provided for each client, allowing for intelligent content-based routing decisions.
✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →
One email each morning: the day's tech stories, clustered across outlets and summarized. No account needed.
One email a day. Unsubscribe in one click, any time.
Spend a few minutes, get the whole day. Every topic's top stories in one hands-free rundown — listen, watch, or read the transcript.
▶ Play today's briefNew every morning, and the back catalogue is archived by date.
Microsoft.Extensions.AI has released new experimental primitives for routing and failover in AI applications, addressing cost, uptime, and latency concerns. These primitives allow developers to route requests based on content or implement failover strategies for AI models and providers.