PHPackages                             fr3on/laravel-ledger - 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. fr3on/laravel-ledger

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

fr3on/laravel-ledger
====================

Token cost accounting and budget enforcement for AI-heavy Laravel applications. Supports OpenAI, Anthropic, Gemini, and more.

0.0.1(3mo ago)0229MITPHPPHP ^8.2CI passing

Since Apr 12Pushed 3mo agoCompare

[ Source](https://github.com/fr3on/laravel-ledger)[ Packagist](https://packagist.org/packages/fr3on/laravel-ledger)[ RSS](/packages/fr3on-laravel-ledger/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Laravel Ledger
==============

[](#laravel-ledger)

[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)[![PHP Version](https://camo.githubusercontent.com/82aff4c49bf07db75f6ce5a63ab76a3e48a07ce938f15c5560101e49379e9969/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253230382e322532422d3737376262342e737667)](https://camo.githubusercontent.com/82aff4c49bf07db75f6ce5a63ab76a3e48a07ce938f15c5560101e49379e9969/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253230382e322532422d3737376262342e737667)[![Laravel Version](https://camo.githubusercontent.com/11208845eb5b5e360e4d372dda2a5354da43559c97c3aba769326f3c71726d72/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302d2d31332d6666326432302e737667)](https://camo.githubusercontent.com/11208845eb5b5e360e4d372dda2a5354da43559c97c3aba769326f3c71726d72/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302d2d31332d6666326432302e737667)[![Tests](https://camo.githubusercontent.com/dc04e4a10589933080325de49f7af7b732b53559934272527ee7abd22bb7a6d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d706573742d3030623162392e737667)](https://camo.githubusercontent.com/dc04e4a10589933080325de49f7af7b732b53559934272527ee7abd22bb7a6d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d706573742d3030623162392e737667)

Token cost accounting for AI-heavy Laravel applications. Tracks spend per user, per feature, and per model. Enforces budgets before calls are made.

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

[](#installation)

```
composer require fr3on/laravel-ledger
php artisan migrate
```

Usage
-----

[](#usage)

Wrap your AI calls with the Ledger facade:

```
use Fr3on\Ledger\Facades\Ledger;

$result = Ledger::for(user: $user, feature: 'chat')
    ->budget()->dailyLimit(tokens: 50_000)->orFail()
    ->track(fn() => $ai->generate($prompt));
```

Expected Result
---------------

[](#expected-result)

The ledger tracks token usage and calculates costs based on your pricing map. You can then generate reports:

```
php artisan ledger:report --period=month
```

**Output Example:**

```
Ledger Report — April 2026

  Feature          Requests   Tokens        Cost (USD)
  ──────────────────────────────────────────────────────
  chat              1,240      4,820,000     $72.30
  summarize           380        940,000     $14.10
  embed             2,100        210,000      $4.20
  ──────────────────────────────────────────────────────
  TOTAL             3,720      5,970,000     $90.60

```

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

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=ledger-config
```

Define your model pricing and token drivers in `config/ledger.php`.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance80

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% 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

Unknown

Total

1

Last Release

103d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/205356416?v=4)[fr3onv](/maintainers/fr3onv)[@fr3onv](https://github.com/fr3onv)

---

Top Contributors

[![fr3on](https://avatars.githubusercontent.com/u/26393383?v=4)](https://github.com/fr3on "fr3on (2 commits)")[![ahmardi](https://avatars.githubusercontent.com/u/141551822?v=4)](https://github.com/ahmardi "ahmardi (1 commits)")

---

Tags

aianthropicbudgetingcost-accountinggeminilaravelopenaiphptoken-trackinglaravelaiopenaiGeminianthropicbudgetingtoken-trackingcost-accounting

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/fr3on-laravel-ledger/health.svg)

```
[![Health](https://phpackages.com/badges/fr3on-laravel-ledger/health.svg)](https://phpackages.com/packages/fr3on-laravel-ledger)
```

###  Alternatives

[spectra-php/laravel-spectra

Comprehensive observability for AI/LLM operations in Laravel applications

182.9k](/packages/spectra-php-laravel-spectra)

PHPackages © 2026

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