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

Laravel Ai Pricing Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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.

  • Quote-time breakage (high, narrow blast radius). Any hard-coded generic identity string in application code, job payloads, or DB rows will stop resolving. Detectable only by exercising the resolution path — static analysis will not catch string-built identities.
  • Silent cost drift (medium). The basis is defined as the maximum over 13 default-routed endpoints across all quantizations and time-of-day overrides. That is deliberately conservative: excellent for budget ceilings and customer-facing quotes, pessimistic for unit-economics modelling. Teams that treat it as "expected cost" will over-forecast.
  • Coverage gaps (medium, accounting risk). Batch, opt-in service tiers, cache writes, and server tools are explicitly out of scope, and the two opt-in DeepInfra flex/priority endpoints are excluded from the max. Workloads using any of these will be under-quoted and will not reconcile against provider invoices.
  • Snapshot staleness (medium, ongoing). The release itself instructs "re-review on endpoint churn" — the risk is organizational, not technical.
  • Nomenclature overload (low but real). identity vs. canonical ID vs. basis vs. alias, with an explicit statement that the basis "is not an alias," creates a naming model that must be documented for non-engineers.

Key questions.

  1. Does fallback-blocking raise a typed exception, return null, or emit a zero-cost quote? The answer determines whether the failure mode is a hard 500 or a silent free-tier miscalculation.
  2. What is the supported mechanism to "configure the generic identity explicitly" — env var, config key, or per-request override — and is that escape hatch intended to be temporary?
  3. Is the generic identity on a deprecation path with a removal version, or permanently available-but-blocked?
  4. What is the snapshot refresh cadence and the published policy for endpoint churn (weekly? on-change? who signs off)?
  5. Is there a diff/validation command to compare v18 → v19 rates for the models we actually use, so the change can be reviewed rather than trusted?
  6. Does the package expose the underlying endpoint set (15, with 13 in scope) for audit, or only the aggregate max?
  7. PHP/Laravel version support matrix for 0.4.x — is this a semver-major-intent behavior change shipped in a patch?

Integration Approach

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.

  1. Pin the snapshot explicitly in config (v19) rather than floating to latest — cost behavior should change only on a reviewed commit.
  2. Inventory every occurrence of the generic identity — code, config, database columns, queue payloads, and any model string built by concatenation. Grep for deepseek-v4.1-flash-1017 and for the provider prefix separately.
  3. For each occurrence, choose: request qualifies for the -standard-max basis → migrate to the qualified identity; or the path genuinely needs live/headline pricing → configure the generic identity explicitly and document why.
  4. Add a resolution test per identity asserting a successful quote, so a future fallback-block is caught in CI rather than in production.

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.

  • Week 1 — staging bump, snapshot pinned to v19, identity inventory complete, resolution tests green.
  • Week 1 — capture v18-vs-v19 quote deltas for top-N models; route any >5% movement to FinOps for sign-off.
  • Week 2 — production deploy behind a flag; shadow-compare live quotes against the old path for one billing cycle.
  • Week 2-3 — reconcile a sample of actual provider invoices against package quotes; document known coverage exclusions (batch, cache writes, server tools, flex/priority) on the internal pricing page.
  • Backlog — quarterly snapshot re-review owned by a named person, triggered additionally on any endpoint-churn advisory.

Operational Impact

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.

  • Hard: unconfigured generic identity throws at quote time in a user-facing path → 5xx. Mitigate with resolution tests and a startup-time validation that every configured identity resolves.
  • Soft: stale snapshot under-quotes after a provider price change; budget alerts fire late and customers are under-billed until the next pin. Mitigate with a freshness assertion on snapshot age.
  • Reconciliation: workloads using batch, cache writes, service tiers, server tools, or the excluded flex/priority endpoints will never tie out to invoices. Mitigate by tagging such workloads as out-of-model rather than pretending coverage.
  • Rollback: only safe if the explicit-identity config mechanism is additive and prior snapshots remain resolvable — verify before cutover.

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.

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.
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox