aaix/laravel-ai-costs

Cost tracking for Laravel AI agents. Calculates API costs from usage metadata across providers.

Maintainers

Package info

github.com/jonaaix/laravel-ai-costs

pkg:composer/aaix/laravel-ai-costs

Statistics

Installs: 55

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.1 2026-05-01 22:31 UTC

This package is auto-updated.

Last update: 2026-05-01 22:48:51 UTC


README

Laravel AI Costs Logo

Laravel AI Costs

Cost tracking for Laravel AI agents. Calculates API costs from usage metadata across providers.

Latest Version on Packagist Total Downloads License

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

License

MIT