spectra-php / laravel-spectra
Observability for AI and LLM calls in Laravel. Automatically tracks requests to OpenAI, Anthropic, Gemini, Mistral and 9 more providers, calculates token and media costs, enforces per-user budgets, and ships a real-time dashboard with OpenTelemetry export.
Fund package maintenance!
Requires
- php: ^8.2
- illuminate/contracts: ^12.0||^13.0
- illuminate/database: ^12.0||^13.0
- illuminate/support: ^12.0||^13.0
- symfony/polyfill-php84: ^1.31
Requires (Dev)
- driftingly/rector-laravel: ^2.0
- james-heinrich/getid3: 2.0.x-dev
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1
- openai-php/laravel: ^0.22.0
- orchestra/testbench: ^10.0||^11.0
- pestphp/pest: ^3.0||^4.0||^5.0
- pestphp/pest-plugin-arch: ^3.0||^4.0||^5.0
- pestphp/pest-plugin-laravel: ^3.0||^4.0||^5.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- rector/rector: ^2.0
Suggests
- james-heinrich/getid3: Required for extracting audio duration from TTS binary responses (minute-based cost calculation)
- openai-php/laravel: Lets Spectra track calls made through the OpenAI facade and client (OpenAiWatcher)
Provides
None
Conflicts
None
Replaces
None
README
AI observability like Langfuse and LangSmith, right inside your Laravel app.
Track every AI call, see what it costs, enforce budgets and test your prompts.
Official Documentation
Official documentation can be found on spectraphp.com.
Upgrading to 4.0
Spectra 4.0 adds scores, alerts, redaction, payload sampling, prompt versions, tool spans, error grouping, review queues, evaluations, a playground and a maintenance screen. Most apps only need to run php artisan spectra:install once. Check the guide if spectra:install runs in a deploy script, if others use your dashboard in production, if your code reads RequestContext::$id, or if you wrote a pricing class. See the upgrade guide and the changelog.
Code of Conduct
We expect all contributors to follow our Code of Conduct.
Security
If you find a security problem, please report it privately, as explained in our security policy. Please don't open a public issue.
Author
This library is created by Ahmad Mayahi with contributions from the Open Source Community.
License
The MIT License (MIT). Please see License File for more information.
