laravel-ai-costs maintained by aaix
Description
Cost tracking for Laravel AI agents. Calculates API costs from usage metadata across providers.
Author
Last update
2026/05/02 00:48
(dev-main)
License
Downloads
75
Zero-config cost calculation for Laravel AI responses. Pricing for 2,600+ models is resolved from the LiteLLM database (cached daily); local overrides take precedence.
composer require aaix/laravel-ai-costs
use Aaix\LaravelAiCosts\Concerns\TracksAiCost;
class MyAgent implements \Laravel\Ai\Contracts\Agent
{
use TracksAiCost; // replaces Promptable
}
$agent = MyAgent::make();
$agent->prompt('...');
$agent->lastCost()->totalCostUsd; // 0.000345
$agent->totalCostUsd(); // sum across all prompts on this instance
Documentation
Full guide and API reference: aaix.github.io/laravel-ai-costs