lmsomeco / laravel-ai-models
List and cache the currently-available models for each provider configured in the Laravel AI SDK.
v1.0.2
2026-08-07 07:39 UTC
Requires
- php: ^8.3
- illuminate/console: ^12.0|^13.0
- illuminate/database: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- laravel/ai: ^0.7|^0.8|^0.9|^0.10
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^3.0
README
A companion package for the Laravel AI SDK (laravel/ai)
that lists and caches the currently-available models for each provider you have
configured. It reads your credentials straight from config/ai.php and keys
everything on the SDK's own Laravel\Ai\Enums\Lab enum, so there's nothing to
configure twice.
Requirements
- PHP 8.3+
laravel/ai^0.7, ^0.8, ^0.9 or ^0.10
Install
composer require lmsomeco/laravel-ai-models php artisan vendor:publish --tag=ai-models-config # optional php artisan vendor:publish --tag=ai-models-migrations # only if using database connectors
Any provider with credentials already set in config/ai.php is picked up
automatically — no extra keys or env vars.
Usage
Artisan
php artisan ai:models # every configured provider php artisan ai:models openai # one provider (a Lab value) php artisan ai:models --refresh # bypass the cache php artisan ai:models openrouter --json
Facade / service
use Laravel\Ai\Enums\Lab; use LmSomeco\AiModels\Facades\AiModels; AiModels::all(); // Collection<AiModel> AiModels::provider(Lab::Anthropic); // accepts a Lab or its string value AiModels::configuredProviders(); // Collection<int, string> of provider names AiModels::refresh(); // clear all cached lists AiModels::refresh(Lab::Groq); // clear one $model = AiModels::provider(Lab::OpenAI)->firstWhere('id', 'gpt-4o'); $model->provider; // Laravel\Ai\Enums\Lab::OpenAI $model->id; // 'gpt-4o' $model->contextWindow; // int|null $model->raw; // untouched provider payload
The ModelRegistry is resolvable from the container if you prefer DI over the
facade.
Provider coverage
Provider (Lab) |
Resolver | Status |
|---|---|---|
OpenAI |
OpenAiCompatibleResolver |
✅ live |
Groq |
OpenAiCompatibleResolver |
✅ live |
Mistral |
OpenAiCompatibleResolver |
✅ live |
DeepSeek |
OpenAiCompatibleResolver |
✅ live |
xAI |
OpenAiCompatibleResolver |
✅ live |
OpenRouter |
OpenRouterResolver |
✅ live (rich metadata, no key needed) |
Anthropic |
AnthropicResolver |
✅ live |
| Gemini, Ollama, Azure, Cohere, ElevenLabs, Bedrock, Jina, VoyageAI | — | ⏳ not yet implemented |
See docs/extending.md for per-provider notes and how to
add a resolver — contributions welcome.
Documentation
- Installation — publish tags, env vars, how credentials are read
- Usage — the
ai:modelscommand and the full facade/DI API - Database connectors — optional DB-backed provider configs
- Caching — cache keys, TTL and busting
- Extending — writing your own
ProviderResolver
License
MIT.