Overview
The automatic model selection system analyzes your task description and selection criteria to recommend the most suitable model from a comprehensive registry of leading AI models including OpenAI, Anthropic, Google, Meta, DeepSeek, Qwen, Mistral, Cohere, and Grok models.Key Features
- Intelligent Analysis: Automatically detects task requirements (reasoning, coding, math, vision, etc.)
- Dual Selection Methods: Choose between fast rule-based or advanced LLM-based selection
- Comprehensive Model Registry: Access to 15+ top-tier AI models with detailed metadata
- Flexible Criteria: Specify constraints like cost, speed, context window, and capabilities
- Confidence Scoring: Get confidence scores and alternative recommendations
- Seamless Integration: Use recommendations directly with your agent
Selection Methods
The framework provides two approaches to model selection:Rule-Based Selection (Default)
Fast, deterministic selection using keyword analysis and scoring algorithms. Ideal for most use cases.- ✅ Fast: No additional API calls required
- ✅ Cost-Effective: No LLM usage for selection
- ✅ Predictable: Consistent results based on rules
- ❌ Limited Context: May miss nuanced requirements
LLM-Based Selection (Advanced)
Uses GPT-4o to analyze your task and intelligently select the best model. Recommended for complex or ambiguous tasks.- ✅ Intelligent: Deep understanding of task nuances
- ✅ Context-Aware: Considers subtle requirements
- ✅ Adaptive: Better handling of complex scenarios
- ❌ Slower: Requires additional API call
- ❌ Cost: Uses tokens for selection process
Basic Usage
Simple Recommendation
Get a model recommendation for any task description:Using the Recommendation
Once you have a recommendation, use it to execute your task:Advanced Usage with Criteria
Specifying Selection Criteria
UseSelectionCriteria to define specific requirements and constraints:
LLM-Based Selection
Enable LLM-based selection for more intelligent recommendations:Async Model Recommendation
For async workflows, use the async version:Selection Criteria Reference
Configure model selection with these criteria parameters:| Criteria | Type | Default | Description |
|---|---|---|---|
| requires_reasoning | bool | None | None | Task needs advanced reasoning capabilities |
| requires_code_generation | bool | None | None | Task involves writing or analyzing code |
| requires_math | bool | None | None | Task requires mathematical problem solving |
| requires_creative_writing | bool | None | None | Task needs creative content generation |
| requires_vision | bool | None | None | Task processes images or visual content |
| requires_audio | bool | None | None | Task processes audio content |
| requires_long_context | bool | None | None | Task needs large context window |
| prioritize_speed | bool | False | Optimize for fast inference |
| prioritize_cost | bool | False | Optimize for cost-effectiveness |
| prioritize_quality | bool | False | Optimize for output quality |
| max_cost_tier | int | None | None | Maximum acceptable cost (1-10, where 10=expensive) |
| min_context_window | int | None | None | Minimum required context window in tokens |
| preferred_provider | str | None | None | Preferred provider (e.g., “openai”, “anthropic”) |
| require_open_source | bool | False | Require open-source model |
| require_production_ready | bool | False | Require production-ready model |
Model Recommendation Output
TheModelRecommendation object provides comprehensive information:
Complete Example: Multi-Task Workflow
Here’s a comprehensive example showing model selection for different task types:Agent-Level Configuration
Configure default selection behavior at agent initialization:Best Practices
- Start with Rule-Based: Use rule-based selection for most tasks - it’s fast and effective
- Use LLM for Ambiguity: Enable LLM-based selection for complex or ambiguous requirements
- Set Cost Limits: Always specify
max_cost_tierfor production applications - Check Alternatives: Review alternative models for flexibility and fallback options
- Monitor Confidence: Low confidence scores (
< 0.7) suggest reviewing criteria or task description - Context Windows: For long documents, always check
min_context_windowrequirements - Production Safety: Use
require_production_ready=Truefor business-critical applications - Provider Preferences: Specify
preferred_providerif you have existing infrastructure - Test Recommendations: Validate model performance with your specific use cases
- Cache Recommendations: Store recommendations for similar tasks to avoid repeated selection
Supported Models
The framework includes comprehensive metadata for:- OpenAI: GPT-4o, GPT-4o-mini, O1-Pro, O1-mini
- Anthropic: Claude 4 Opus, Claude 3.7 Sonnet, Claude 3.5 Haiku
- Google: Gemini 2.5 Pro, Gemini 2.5 Flash
- Meta: Llama 3.3 70B
- DeepSeek: DeepSeek-Reasoner, DeepSeek-Chat
- Qwen: Qwen 3 235B
- Mistral: Mistral Large, Mistral Small
- Cohere: Command R+
- Grok: Grok 4

