PHPackages                             illuma-law/healthcheck-ai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. illuma-law/healthcheck-ai

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

illuma-law/healthcheck-ai
=========================

Focused AI failover chain and agent registry health checks for Spatie's Laravel Health package.

v0.1.4(1mo ago)062MITPHPPHP ^8.3CI passing

Since Apr 20Pushed 1mo agoCompare

[ Source](https://github.com/illuma-law/healthcheck-ai)[ Packagist](https://packagist.org/packages/illuma-law/healthcheck-ai)[ Docs](https://github.com/illuma-law/healthcheck-ai)[ RSS](/packages/illuma-law-healthcheck-ai/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (17)Versions (6)Used By (0)

Healthcheck AI for Laravel
==========================

[](#healthcheck-ai-for-laravel)

[![Tests](https://github.com/illuma-law/healthcheck-ai/actions/workflows/run-tests.yml/badge.svg)](https://github.com/illuma-law/healthcheck-ai/actions)[![Packagist License](https://camo.githubusercontent.com/e60623f508586f049d48cfb8396ee411b0c9bc3be174381a1893c37462a3c1e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e63652d4d49542d626c7565)](http://choosealicense.com/licenses/mit/)[![Latest Stable Version](https://camo.githubusercontent.com/47823e3a956ea698bf365dd6921a91ae7c38faa6805f3ab8c27878ec00e28d49/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696c6c756d612d6c61772f6865616c7468636865636b2d61693f6c6162656c3d56657273696f6e)](https://packagist.org/packages/illuma-law/healthcheck-ai)

A comprehensive suite of AI health checks for Spatie's [Laravel Health](https://spatie.be/docs/laravel-health/v1/introduction) package.

This package provides robust health checks specifically designed to monitor your AI integrations, ensuring that your LLM prompt providers, embedding chains, and AI Agent registries are operational and properly configured.

Features
--------

[](#features)

- **Prompt Chain Check:** Validates your LLM failover chains (e.g., OpenAI → Anthropic) by sending a small canary prompt.
- **Embedding Chain Check:** Verifies that your embedding providers are generating vectors with the expected dimensions.
- **Agent Registry Check:** Inspects your AI agents to ensure that `Model` and `Provider` attributes are present and that the corresponding API credentials exist in your environment.
- **Caching:** Expensive API calls to AI providers are cached to prevent your health check endpoint from exhausting your rate limits.

Installation
------------

[](#installation)

Require this package with composer:

```
composer require illuma-law/healthcheck-ai
```

Configuration
-------------

[](#configuration)

You can publish the configuration file to customize the default cache TTLs, embedding dimensions, and canary texts used during the checks:

```
php artisan vendor:publish --tag="healthcheck-ai-config"
```

This will create a `config/healthcheck-ai.php` file:

```
return [
    // How long to cache embedding check results to save API calls
    'embedding_cache_ttl_seconds' => 300,

    // Default expected dimensions for vector embeddings
    'embedding_dimensions' => 1024,

    // The short text sent to the embedding provider
    'embedding_canary_text' => 'AI embedding health check',

    // How long to cache the LLM prompt check results
    'prompt_cache_ttl_seconds' => 300,

    // The prompt sent to the LLM to verify it is responsive
    'prompt_text' => 'Reply with exactly: OK',

    // Request timeout in seconds
    'prompt_timeout_seconds' => 25,
];
```

Usage &amp; Integration
-----------------------

[](#usage--integration)

Add the checks to your `Health::checks()` registration within a Service Provider (usually `AppServiceProvider`).

### 1. Prompt Chain Check

[](#1-prompt-chain-check)

This check monitors a sequence of LLM providers. If the primary provider fails but a fallback succeeds, it marks the health check as degraded (Warning) instead of failing completely.

```
use IllumaLaw\HealthCheckAi\AiPromptChainHealthCheck;
use Spatie\Health\Facades\Health;

Health::checks([
    AiPromptChainHealthCheck::new()
        ->cacheTtl(600) // Optional override
        ->timeout(10) // Optional override
        ->resolveChainUsing(function () {
            // Define your fallback chain
            return [
                ['provider' => 'openai', 'model' => 'gpt-4o'],
                ['provider' => 'anthropic', 'model' => 'claude-3-5-sonnet-latest'],
            ];
        }),
]);
```

### 2. Embedding Chain Check

[](#2-embedding-chain-check)

This check is vital if you rely on vector embeddings (e.g., pgvector or Typesense). It queries your embedding models and verifies that the output vectors match your expected dimensions.

```
use IllumaLaw\HealthCheckAi\AiEmbeddingChainHealthCheck;
use Spatie\Health\Facades\Health;

Health::checks([
    AiEmbeddingChainHealthCheck::new()
        ->dimensions(1536) // e.g., OpenAI text-embedding-3-small
        ->resolveChainUsing(function () {
            return [
                ['provider' => 'openai', 'model' => 'text-embedding-3-small'],
            ];
        }),
]);
```

### 3. Agent Registry Check

[](#3-agent-registry-check)

If you are using the `laravel/ai` SDK with attributes for Agents, this check inspects a given list of Agent classes using PHP Reflection. It verifies that each class defines its `Provider` and `Model` attributes and that your application has the credentials required for that provider.

```
use IllumaLaw\HealthCheckAi\AiAgentRegistryCheck;
use Spatie\Health\Facades\Health;

Health::checks([
    AiAgentRegistryCheck::new()
        ->resolveAgentsUsing(function () {
            // Return a list of your Agent class names
            return [
                 \App\Agents\SupportAgent::class,
                 \App\Agents\SummarizerAgent::class,
            ];
        })
        ->hasCredentialsUsing(function (string $provider) {
            // Define how to check if credentials exist for a given provider
            if ($provider === 'openai') {
                return !empty(config('ai.providers.openai.api_key'));
            }
            if ($provider === 'anthropic') {
                return !empty(config('ai.providers.anthropic.api_key'));
            }
            return false;
        }),
]);
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance91

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

5

Last Release

44d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2affac64f2726a640084b203503518ca01f582536d60a0a299b614486ed95aaa?d=identicon)[miguelenes](/maintainers/miguelenes)

---

Top Contributors

[![miguelenes](https://avatars.githubusercontent.com/u/1568086?v=4)](https://github.com/miguelenes "miguelenes (10 commits)")

---

Tags

laravelhealthaillmilluma-law

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/illuma-law-healthcheck-ai/health.svg)

```
[![Health](https://phpackages.com/badges/illuma-law-healthcheck-ai/health.svg)](https://phpackages.com/packages/illuma-law-healthcheck-ai)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)[laracraft-tech/laravel-useful-additions

A collection of useful Laravel additions!

58122.8k](/packages/laracraft-tech-laravel-useful-additions)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
