laravel/ai

Add Per-provider model configuration for failover

クローズ

#182 opened on 2026/02/18

 (2 件のコメント) (6 件のリアクション) (0 人の担当者)PHP (261 件のフォーク)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (978 個のスター)
PR merge metrics
 (平均マージ 6d 11h) (30d で 49 merged PRs)

説明

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',
]);

コントリビューターガイド