← ClaudeAtlas

laravel-ai-multi-providerlisted

Multi-provider AI chat and vision with automatic fallback when quota, rate limits, or model unavailability occur. Use when integrating Gemini, OpenRouter, OpenAI, or Claude in Laravel with resilient error messages.
Yaz-inc/yazinc-ai-toolkit · ★ 0 · AI & Automation · score 60
Install: claude install-skill Yaz-inc/yazinc-ai-toolkit
# Laravel AI Multi-Provider + Fallback Single `AiService` routes to configured provider; on retryable failures, walks a **fallback chain** (same provider alt models → cross-provider plan in config). ## When to use - Production AI features that must survive free-tier quota exhaustion - Chat + vision share one fallback infrastructure - User-friendly errors instead of raw API JSON ## Stack - Laravel 10, Guzzle/Http facade - Settings from `laravel-json-ai-settings` - Config: `config/ai.php` → `fallback_plan`, `fallback_models`, `label_scan.vision_models` ## Architecture ``` User message / image → primary provider + model (from settings) → executeWithFallbackChain(mode, provider, model, invoke) → buildFallbackChain('chat'|'label_scan', ...) → foreach step: skip if no API key; try invoke; catch retryable → next → formatAiErrorMessage() on final failure ``` ## Config: fallback_plan ```php 'fallback_plan' => [ 'enabled' => true, 'chat' => [ ['provider' => 'openrouter', 'models' => ['openrouter/free', 'meta-llama/llama-3.3-70b-instruct:free']], ['provider' => 'gemini', 'models' => ['gemini-2.5-flash-lite', 'gemini-2.0-flash-lite']], ], 'label_scan' => [ ['provider' => 'openrouter', 'models' => ['openrouter/free', 'nvidia/nemotron-nano-12b-v2-vl:free']], ['provider' => 'gemini', 'models' => ['gemini-2.5-flash-lite', 'gemini-2.5-flash']], ], ], ``` ## Retryable errors Treat as fallback-worthy (cas