Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 16, 2025

This PR adds a comprehensive how-to article that demonstrates how to dynamically switch between different AI model providers using Microsoft.Extensions.AI. The article addresses the key scenarios outlined in the issue:

New Content

Article: docs/ai/how-to/switch-model-providers.md

  • Environment-based switching (development vs production)
  • Smart routing based on query complexity
  • Batch evaluation across multiple providers
  • Configuration-driven provider selection
  • Dependency injection patterns with keyed services

Code Examples: Five complete, working examples with project files:

  1. Environment switching: Local Ollama for development, Azure OpenAI for production
  2. Smart routing: Automatic provider selection based on query characteristics
  3. Batch evaluation: Compare responses across multiple providers
  4. Configuration-based: JSON-driven provider configuration
  5. Dependency injection: Register multiple providers with DI container

Technical Details

All code examples:

  • Target .NET 8.0 with compatible package versions
  • Build successfully without errors
  • Follow Microsoft.Extensions.AI best practices
  • Include proper error handling and fallback strategies

The article also includes comprehensive best practices covering:

  • Error handling and fallback mechanisms
  • Performance monitoring and logging
  • Cost optimization strategies
  • Provider-specific configuration patterns

Navigation

Updated docs/ai/toc.yml to add a new "How-to guides" section containing the article, properly integrated into the existing documentation structure.

This expands significantly on the blog post content referenced in the issue, providing production-ready examples that developers can immediately implement in their applications.

Fixes #48552.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] [New article]: Add how-to that shows how to switch model providers with Microsoft.Extensions.AI Add how-to article: Switch model providers with Microsoft.Extensions.AI Sep 16, 2025
@Copilot Copilot AI requested a review from luisquintanilla September 16, 2025 21:52
Copilot finished work on behalf of luisquintanilla September 16, 2025 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New article]: Add how-to that shows how to switch model providers with Microsoft.Extensions.AI
2 participants