illuma-law / healthcheck-ai
Focused AI failover chain and agent registry health checks for Spatie's Laravel Health package.
Requires
- php: ^8.3
- illuminate/contracts: ^11.0||^12.0||^13.0
- illuminate/database: ^11.0||^12.0||^13.0
- illuminate/support: ^11.0||^12.0||^13.0
- laravel/ai: ^0.6.0
- spatie/laravel-health: ^1.39
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- mrpunyapal/peststan: ^0.2.12
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^11.1.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-23 14:05:57 UTC
README
A Spatie Laravel Health add-on for checking Laravel AI prompt chains, embedding chains, and agent registries.
Requires PHP 8.3+, Laravel 11–13, Laravel AI SDK 0.6+, and Spatie Laravel Health 1.39+.
Install
composer require illuma-law/healthcheck-ai php artisan vendor:publish --tag=healthcheck-ai-config
Register checks
Add the checks to your health registration. Configure the same provider and model names used by your application. These checks make provider requests, so enable caching and use a small, low-cost canary.
use IllumaLaw\HealthCheckAi\AiPromptChainHealthCheck; use IllumaLaw\HealthCheckAi\AiEmbeddingChainHealthCheck; use Spatie\Health\Facades\Health; Health::checks([ AiPromptChainHealthCheck::new() ->resolveChainUsing(fn () => [ ['provider' => 'openai', 'model' => 'gpt-4o-mini'], ]), AiEmbeddingChainHealthCheck::new() ->dimensions(1536) ->resolveChainUsing(fn () => [ ['provider' => 'openai', 'model' => 'text-embedding-3-small'], ]), ]);
When a primary model fails but a fallback works, the chain check reports a warning. The embedding check also warns when a returned vector has the wrong dimension. The agent registry check validates configured agent classes and credential availability:
use IllumaLaw\HealthCheckAi\AiAgentRegistryCheck; AiAgentRegistryCheck::new() ->resolveAgentsUsing(fn () => [App\Agents\SupportAgent::class]) ->hasCredentialsUsing(fn (string $provider) => filled(config("ai.providers.{$provider}.api_key")));
Published settings in config/healthcheck-ai.php control cache TTLs, the
embedding dimension and canary text, and prompt timeout and canary text.
Test
composer test
composer analyse
vendor/bin/pint --test
MIT licensed. See LICENSE.
