Skip to main content
Upsonic Agent Framework includes an intelligent model selection system that automatically recommends the most appropriate AI model for your specific task. This feature helps you optimize performance, cost, and speed by selecting the best model based on task requirements and constraints.
Model selection system may recommend models from various providers (OpenAI, Anthropic, Google, etc.). Ensure you have the required API keys configured for the recommended model’s provider before using it. If authentication is not set up for the recommended model, the agent will fail at runtime. Always verify you have the necessary credentials, or use the preferred_provider criteria to limit recommendations to providers you have configured.

Overview

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

Use SelectionCriteria 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:

Model Recommendation Output

The ModelRecommendation 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

  1. Start with Rule-Based: Use rule-based selection for most tasks - it’s fast and effective
  2. Use LLM for Ambiguity: Enable LLM-based selection for complex or ambiguous requirements
  3. Set Cost Limits: Always specify max_cost_tier for production applications
  4. Check Alternatives: Review alternative models for flexibility and fallback options
  5. Monitor Confidence: Low confidence scores (< 0.7) suggest reviewing criteria or task description
  6. Context Windows: For long documents, always check min_context_window requirements
  7. Production Safety: Use require_production_ready=True for business-critical applications
  8. Provider Preferences: Specify preferred_provider if you have existing infrastructure
  9. Test Recommendations: Validate model performance with your specific use cases
  10. 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
Each model includes benchmark scores (MMLU, HumanEval, MATH, etc.), capabilities, cost/speed tiers, and use case recommendations.

Common Use Cases

Banking & Finance

Customer Support

Research & Development

The automatic model selection system empowers your AI agent framework to dynamically optimize model usage based on task requirements, delivering the best balance of performance, cost, and speed for your specific banking and fintech applications.