lunetics/llm-cost-tracking-bundle
Lunetics LLM Cost Tracking Bundle helps Symfony/PHP apps monitor LLM API usage and estimate spend across providers and models. Track token counts, attribute costs to users or features, set budgets, and review usage via dashboards and reports.
Architecture fit. The package in question is LuneticsLlmCostTrackingBundle — a Symfony bundle, not a Laravel package. That is the single most important finding. Its value proposition (attaching a cost-tracking layer to outbound LLM API calls and surfacing the result in the Symfony Web Profiler) depends on Symfony's HttpClient decorator/event system and framework-bundle profiler infrastructure. Laravel ships some Symfony components (Console, HttpFoundation, Routing, VarDumper) but neither the full HttpClient event pipeline as the default HTTP layer nor the Profiler bundle. A Laravel application cannot consume this as-is; a Laravel app's HTTP calls flow through Guzzle via Illuminate\Support\Facades\Http, which the bundle does not instrument.
Integration feasibility. Two viable paths, both with real cost:
Http:: macros plus a Telescope watcher. This is days of work, not hours, but yields something actually maintainable on our stack.Direct composer require into a Laravel app is not a realistic option.
Technical risk. Moderate and concentrated in three places:
CostTrackerInterface changed to surface skipped calls. Any custom CostTrackerInterface implementation we write is now a maintenance liability with no stability guarantee until 1.0.@lunetics). Bus-factor of one. No commercial support tier indicated.Key questions for the maintainer / spike:
CostTrackerInterface (added methods vs. changed signatures)? Is it implementable in a backward-compatible way with an abstract base class?Symfony\Contracts\HttpClient, or is there a transport-agnostic hook we could drive from Guzzle middleware?Stack fit. Poor for the stated Laravel/PHP target — this is a Symfony-native package and the mismatch is architectural, not cosmetic. The profiler panel, the headline feature of v0.6.0, has no Laravel analogue; the closest equivalent is Telescope, which would require a custom watcher regardless.
Migration path. Do not adopt 0.6.0 into a Laravel codebase. Recommended sequence:
Compatibility. Confirm PHP floor and Symfony version constraint from composer.json before any spike. Laravel 10/11 will pull compatible Symfony component versions but will not satisfy a symfony/framework-bundle or symfony/http-client requirement in a way that makes the profiler integration functional. Assume incompatible until proven otherwise.
Sequencing. Spike → decide → (if build) define the cost-event schema and price-table ownership → implement Laravel HTTP middleware + Telescope watcher → instrument staging → production with fail-open guard. Ship behind a config flag so the tracker can be disabled without a deploy.
Maintenance. Highest ongoing cost is the pre-1.0 churn. Every minor release may break CostTrackerInterface; at the current cadence that is roughly one breaking change per release cycle. Budget for either a vendored fork or a hard version pin with a documented upgrade ritual. Neither is free.
Support. Community-only. No SLA, no vendor escalation path. If cost attribution becomes a billing or chargeback input, that is an unacceptable support posture and argues for the in-house build.
Scaling. Two distinct profiles:
Failure modes.
Ramp-up. Low for a Symfony-fluent engineer (an afternoon). Higher for a Laravel-only team: the bundle's concepts map cleanly, but the framework idioms (service tags, compiler passes, profiler data collectors) do not, and that translation overhead is exactly why the build-vs-adopt decision should not be made by the most Symfony-literate person on the team alone.
How can I help you explore Laravel packages today?