fr3on/laravel-ledger
最新稳定版本:0.0.1
Composer 安装命令:
composer require fr3on/laravel-ledger
包简介
Token cost accounting and budget enforcement for AI-heavy Laravel applications. Supports OpenAI, Anthropic, Gemini, and more.
README 文档
README
Token cost accounting for AI-heavy Laravel applications. Tracks spend per user, per feature, and per model. Enforces budgets before calls are made.
Installation
composer require fr3on/laravel-ledger php artisan migrate
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
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
Publish the config file:
php artisan vendor:publish --tag=ledger-config
Define your model pricing and token drivers in config/ledger.php.
统计信息
- 总下载量: 229
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-12