amarenkov/laravel-mutable-content-ai
A Laravel package for working with mutable AI-generated content, letting you store, edit, and refresh model output while keeping it versioned and easy to manage in your application.
Services\Spending (runs(), total(), daily()) plus Run::cost() turn raw AI usage into per-user, per-model, per-currency cost data — the input needed to decide seat-based vs. usage-based vs. credit-based pricing.Models\BalanceEntry and Services\Balances (topUp(), setActual(), remaining()) enable a prepaid wallet model (buy credits, draw down by usage) without building a ledger from scratch. remaining() is explicitly an estimate (latest actual + top-ups − subsequent costs), which is fine for gating and UX but not for invoicing.prices config key with separate cache read/write prices means you can model gross margin per customer, per feature, and per model — and quantify whether prompt caching is actually paying for itself.Run::FIELD_CACHE_READ_TOKENS / FIELD_CACHE_WRITE_TOKENS), you can A/B cheaper models or aggressive caching and measure the cost delta instead of guessing.Adopt when:
LovsSeeder and FieldsSeeder after the extend_ai_tables_with_balance migration. Pin versions and read changelogs on every bump.prices config: published model prices are your responsibility to keep current, and stale prices silently produce wrong margins.Look elsewhere when:
To executives: v0.5.0 adds the financial plumbing for AI features — per-user cost tracking, spend reporting by day/model/currency, and a prepaid credit balance. That means we can launch usage-based or credit-based pricing without a custom metering build, see gross margin per customer from day one, and cap credit exposure. Treat it as an 80% solution for cost visibility, not a replacement for our billing system.
To engineering: the release is additive — no breaking changes listed. It introduces a prices config (with distinct cache prices), two run-journal fields for cache tokens, Services\Costs / Services\Spending / Services\Balances, and a new ai.balance_entries table via the extend_ai_tables_with_balance migration. Required ops step: run the migration, then LovsSeeder and FieldsSeeder. Because we're on 0.x, pin the version and review each minor bump. remaining() is a computed estimate, so don't let it back authoritative billing logic.
Recommended next steps: spike the migration + seeders in staging, validate Spending::daily() against a week of real traffic, and confirm the prices key is populated for every model we actually call before shipping any customer-facing spend UI.
How can I help you explore Laravel packages today?