Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Llm Cost Tracking Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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:

  1. Adopt only in a Symfony service. If the org has any Symfony workload calling LLMs, this is a low-effort, high-signal observability win.
  2. Extract, don't install. Treat the cost-table and accounting logic as reference implementation and re-implement it as a Laravel middleware on 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:

  • Pre-1.0 API churn. v0.6.0 is already the second breaking release in the 0.5→0.6 window. CostTrackerInterface changed to surface skipped calls. Any custom CostTrackerInterface implementation we write is now a maintenance liability with no stability guarantee until 1.0.
  • Single-maintainer OSS (@lunetics). Bus-factor of one. No commercial support tier indicated.
  • Data sensitivity. Cost tracking implies capturing request metadata — model name, token counts, potentially prompt/response content. Need to confirm what is persisted and where before this touches production traffic.

Key questions for the maintainer / spike:

  • What is the exact signature delta on CostTrackerInterface (added methods vs. changed signatures)? Is it implementable in a backward-compatible way with an abstract base class?
  • Is the HTTP instrumentation coupled to Symfony\Contracts\HttpClient, or is there a transport-agnostic hook we could drive from Guzzle middleware?
  • How is the price table sourced — hardcoded, config-published, remotely updated? Who owns drift when providers change pricing?
  • Does the tracker fail open or fail closed if cost computation throws? A tracker exception must never break an LLM call.
  • What is persisted, at what retention, and does it capture prompt content (PII exposure)?
  • PHP and Symfony version floor for 0.6.0.

Integration Approach

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:

  1. Pin nothing yet. There is no existing dependency, so there is no migration debt — preserve that position until the spike concludes.
  2. Run a time-boxed spike (2–3 days) against a scratch Symfony 7 app to evaluate the bundle's actual tracking fidelity across our providers (OpenAI, Anthropic, etc.), and to read the 0.6.0 interface change directly.
  3. Decide build-vs-adopt on the spike output. Given the stack mismatch, the expected outcome is build a thin Laravel-native equivalent, using this bundle as a design reference for skipped-call accounting and cost-table structure.
  4. If a Symfony service exists in the estate, adopt there independently and in parallel — it is a genuinely cheap win in that context.

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.

Operational Impact

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:

  • Profiler panel is dev/test only — zero production cost, which also means v0.6.0's headline feature delivers no production value.
  • Tracking layer adds per-call overhead (token counting, price lookup) and unbounded storage growth on the cost-event table. Needs a retention policy and an index on tenant/model/time from day one.

Failure modes.

  • Fail-closed tracker — an exception in cost computation propagates and kills the LLM call. This is the highest-severity risk and must be verified, not assumed. Wrap in try/catch regardless of vendor behavior.
  • Silent undercount — the very problem 0.6.0 addresses. Prior versions dropped skipped calls without signal; any historical cost data from 0.5.x is understated and should not be used for reconciliation.
  • Price-table drift — provider pricing changes silently misattribute cost. Needs an owner and a review cadence.
  • Instrumentation gaps — calls made outside the instrumented HTTP client (SDK-native clients, queued jobs, streaming endpoints) are invisible, producing a confidently wrong total.

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log