- How do I install backtik-ch/laravel-ai-usage in a Laravel application?
- Install it with Composer by running composer require backtik-ch/laravel-ai-usage; the package is a Laravel-native library that registers through a service provider. After installing, publish the package config and any migrations with the vendor publish command, then run php artisan migrate against a non-production database first. Because v1.0.7 is a patch release, the published config and migration surface should match earlier 1.0.x versions, but confirm the exact publish tags in the repository README before rolling out.
- Does the package log AI requests and token usage automatically, or do I have to call it manually?
- The package advertises automatic logging of AI requests, token counts, model metadata, and estimated cost, which suggests metering is wired through Laravel's service container or an event listener rather than hand-written calls. The release notes are terse, so verify whether your AI calls must go through a package wrapper or manager to be captured. If instrumentation is opt-in per call site, funnel all AI traffic through a single internal client and bind the meter there so new call sites cannot silently escape metering.
- Which AI providers and model SDKs does backtik-ch/laravel-ai-usage support?
- The package is described as capturing provider, model, token, and cost metadata from supported AI providers, but the overview does not enumerate them. Before adopting, check the README or config file for the provider list and the SDK versions it recognises, especially if you call OpenAI, Anthropic, or a self-hosted model through your own HTTP client. Any provider the package cannot identify will likely be logged without reliable pricing, so plan for manual cost overrides or a custom driver for those.
- Is this package compatible with Laravel 10 and 11 and PHP 8.1+?
- It is built as a Laravel-native package with a service provider, config file, Eloquent-backed storage, and Artisan commands, which points to Laravel 10/11 and PHP 8.1+ as the expected baseline. The published Composer metadata is the authority here, so check the require block for the exact laravel/framework and php constraints before adding it to an existing app. If you run an older Laravel release, confirm support in the repository issues rather than assuming the constraints are loose.
- How does cost estimation work, and can I override pricing for unknown or custom models?
- Cost estimation is calculated per provider, model, user, or tenant from the token counts the package records, so accuracy depends on its pricing table matching current provider rates. The overview mentions cost estimation but does not document an override mechanism, so look for a config-level unit price map or a custom pricing resolver before you rely on the numbers for chargeback. Treat the estimates as internal visibility rather than billing-grade figures, and reconcile periodically against provider invoices.
- Does laravel-ai-usage store my prompts and responses, and what are the PII implications?
- The package is positioned as usage metering and auditing: requests, token counts, model metadata, and estimated cost, which is metadata rather than conversation content. Content capture is not described in the overview, so confirm in the config and migration files whether any prompt or response text columns exist before enabling it in production. If content is stored, apply your data-retention policy, redaction rules, and access controls to those tables just as you would to any other PII-bearing store.
- How do I set usage limits and alerts per user or tenant?
- The package supports configurable usage limits and alerts alongside per-user and per-tenant cost attribution, which is what makes it usable for enforcing spend policy rather than just reporting. Limits are configured through the published config file, so publish it first, define thresholds keyed by tenant or user, then confirm how the alert is delivered (log, event, or notification) in the docs. Because enforcement is only as good as the recorded data, make sure every AI call site is instrumented before you treat a limit as a hard guarantee.
- What database tables does it add, and how much write volume should I expect?
- Storage is Eloquent-backed with publishable migrations, so expect at least one usage or request table plus whatever aggregation the reports rely on. The overview does not state whether rows are written per request or rolled into counters, and that choice drives write volume at high traffic, so check the migration and model code before enabling it on a busy endpoint. On high-volume applications, consider queueing or batching writes and run the migrations in a staging environment first.
- Can I export usage data to Prometheus, OpenTelemetry, or a data warehouse?
- Out of the box the package provides Artisan commands and reports for usage analysis inside the Laravel app, which covers ad hoc cost review but is not a metrics exporter. There is no documented export driver in the overview, so plan to read from its Eloquent models directly, schedule a query into your warehouse, or add a custom exporter behind your own interface. Keeping the package as a leaf dependency bound at a single choke point makes that bridge straightforward and lets you swap the meter later.
- Is backtik-ch/laravel-ai-usage actively maintained, and what changed in v1.0.7?
- v1.0.7 is a patch release whose notes are only a changelog comparison link with no enumerated changes, so under semver expect backward-compatible fixes and no migration changes. It is a single-maintainer package at v1.0.x, so review the commit history and open issues before committing, and pin the version in composer.json. Alternatives include building a lightweight internal meter around your AI client or pairing provider-side usage APIs with your existing observability stack.