laravel/ai

Add Per-provider model configuration for failover

Chiusa

#182 aperta il 18 feb 2026

 (2 commenti) (6 reazioni) (0 assegnatari)PHP (261 fork)github user discovery
enhancementhelp wanted

Metriche repository

Star
 (978 stelle)
Metriche merge PR
 (Merge medio 6g 11h) (49 PR mergiate in 30 g)

Descrizione

Problem

When using multiple providers as failover, there's no way to specify a different model per provider. Each provider typically requires its own model identifier (e.g. gpt-5-mini for OpenAI, mistral-large-latest for Mistral), but the current API only accepts a single model value.

Current behavior

Via attributes:

#[Provider([Lab::OpenAI, Lab::Mistral])]
#[Model('gpt-5-mini')]
class WorkoutProgrammerAgent implements Agent, Conversational, HasTools

#[Model] only accepts one value — there's no way to map a model to each provider.

Via prompt method:

(new WorkoutProgrammerAgent($workoutPlan))
    ->prompt((string) $prompt, provider: [Lab::OpenAI, Lab::Mistral], model: 'gpt-5-mini');

Same limitation — model is a single string with no per-provider mapping.

Expected behavior

Something like:

#[Provider([Lab::OpenAI, Lab::Mistral])]
#[Model(['gpt-5-mini', 'mistral-large-latest'])]

or:

->prompt($prompt, provider: [
    Lab::OpenAI => 'gpt-5-mini',
    Lab::Mistral => 'mistral-large-latest',
]);

Guida contributor