jkudish/laravel-ai-pricing
A Laravel package for calculating and tracking AI model costs. Define pricing for providers like OpenAI and Anthropic in config, estimate token-based expenses per request, and keep cost logic centralized so you can bill users, monitor spend, or compare models.
Architecture fit. The package occupies the pricing-identity layer between application code and LLM providers: canonical model IDs (deepseek/deepseek-v4.1-flash-20261017), provider-scoped route identities (openrouter:...), and qualified bases (-standard-max) that carry the rate contract. For a Laravel estate this is a natural fit as a container-bound pricing service behind config, consumed by job dispatch, quota/budget middleware, and cost-attribution code. Snapshot v19 is pure data plus a resolution-policy tightening — no new architectural surface — so the shape remains: config → snapshot catalog → resolved basis → quote.
Integration feasibility. This is a low-effort upgrade mechanically (composer bump, publish/refresh config, warm cache) and a medium-effort upgrade behaviorally. The Changed entry is the real payload: the generic openrouter:deepseek/deepseek-v4.1-flash-1017 identity is now fallback-blocked, meaning any code path that previously resolved a price by falling back to a live catalog or a Portkey headline number will now fail or require explicit configuration. That is a fail-closed policy change, and it is the item that determines whether v0.4.2 is a drop-in or a config-migration.
Technical risk.
Key questions.
null, or emit a zero-cost quote? The answer determines whether the failure mode is a hard 500 or a silent free-tier miscalculation.Stack fit. Idiomatic Laravel: service provider registration, publishable config holding the pinned snapshot and any explicit identity overrides, cache-store backing for the resolved catalog, and container binding so pricing can be faked in tests. Fits cleanly alongside queue workers (cost stamping on job dispatch), HTTP middleware (pre-flight budget checks), and existing FinOps export jobs.
Migration path.
v19) rather than floating to latest — cost behavior should change only on a reviewed commit.deepseek-v4.1-flash-1017 and for the provider prefix separately.-standard-max basis → migrate to the qualified identity; or the path genuinely needs live/headline pricing → configure the generic identity explicitly and document why.Compatibility. Treat v0.4.2 as behaviorally breaking despite the patch number. Coordinate with the release that introduces the explicit-config mechanism, and confirm whether v18 snapshots remain resolvable so a rollback is a config change rather than a code revert.
Sequencing.
Maintenance. The recurring cost is catalog stewardship, not code. Budget a standing quarterly review plus an on-call trigger for endpoint churn, and assign an owner — "re-review on endpoint churn" is a directive with no built-in enforcement. Because time-of-day overrides are folded into the max, the same model can legitimately price differently across runs; the review process must accept that as intended rather than chasing phantom drift.
Support. Expect two recurring ticket classes: (a) "the quote is higher than the provider billed" — answer is the max-over-endpoints basis plus excluded tiers; (b) "pricing stopped working after deploy" — answer is the fallback block and the required explicit config. Both are documentation problems before they are engineering problems. Publish a short glossary (identity / canonical / basis / alias) and a one-page "why our number differs from the invoice" note; this is the highest-leverage operational artifact for this release.
Scaling. Snapshot resolution is static data behind a cache, so per-request cost is negligible and scales horizontally without concern. The scaling pressure is combinatorial: models × endpoints × quantizations × time-of-day overrides × qualified bases grows the catalog and the review surface, not the runtime. Watch config file size and cache warm-up time as the model list grows; prefer keyed lookups over full-catalog hydration.
Failure modes.
Ramp-up. A Laravel developer can consume the API in under an hour; the real onboarding is the pricing semantics — roughly a half-day for whoever owns cost reporting, and a short briefing for finance/support so quoted numbers are defended consistently. Plan one pairing session between the implementing engineer and the FinOps owner during the v18→v19 delta review; that single session covers most of the institutional knowledge transfer this release requires.
How can I help you explore Laravel packages today?