Search by

gometap / larai-tracker

develop-gmt

A standalone dashboard to track AI token usage and API costs for Laravel applications.

Package info

github.com/Gometap/larai-tracker

Language:Blade

pkg:composer/gometap/larai-tracker

Statistics

Installs: 525

Dependents: 0

Suggesters: 0

Stars: 9

Open Issues: 0

v1.2.0 2026-10-01 06:28 UTC

README

Larai Tracker Logo

Larai Tracker ๐Ÿš€

Latest Version on Packagist Total Downloads Tests

Larai Tracker is a standalone dashboard for tracking AI token usage and estimated USD API costs in Laravel applications. It observes supported requests made through Laravel's Http client for OpenAI, Anthropic, Gemini, Azure OpenAI, and OpenRouter without changing the calling code.

Supports Laravel 10, 11, and 12.

Screenshots

Dashboard

Dark Preview Light Preview

Logs

Logs Preview

Features

  • ๐Ÿ•ต๏ธ Automatic Tracking: Logs documented token usage from supported Laravel HTTP client responses.
  • ๐Ÿ“Š Premium Dashboard: Access a high-end AI analytics center at /larai-tracker.
  • ๐Ÿ” Singleton Authentication: Rate-limited, password-protected owner dashboard with secure first setup.
  • ๐Ÿ’ฐ Honest Cost Estimates: Versioned USD catalog, manual overrides, and explicit unavailable-price states.
  • ๐ŸŒ Multi-Provider Support: OpenAI, Anthropic, Azure OpenAI, Gemini, and OpenRouter endpoint adapters.
  • โš™๏ธ Dynamic Pricing: Sync latest prices or manually override model costs from the UI.
  • ๐Ÿ“ฆ Large-data Safety: Streamed exports, indexed date filters, and scheduled batched retention.

Installation

Install the package via composer:

composer require gometap/larai-tracker

Publish and run the migrations:

php artisan vendor:publish --tag="larai-tracker-migrations"
php artisan migrate

In production, configure either a permanent dashboard password or a temporary first-setup token:

LARAI_TRACKER_PASSWORD=a-long-random-password
# Or, only until the first password is saved:
LARAI_TRACKER_SETUP_TOKEN=a-long-random-owner-controlled-token

(Optional) Publish the configuration:

php artisan vendor:publish --tag="larai-tracker-config"

Usage

๐Ÿ•ต๏ธ Automatic Tracking

Once installed, the package observes successful calls made through Laravel's Http facade. It does not observe provider SDKs that bypass Laravel's HTTP client, streamed responses that do not emit a complete supported usage payload, or arbitrary OpenAI-compatible hosts.

Provider Supported endpoint shape Usage fields
OpenAI /v1/chat/completions, /v1/responses prompt/completion or input/output tokens
Anthropic /v1/messages input/output tokens
Gemini model generateContent URLs usageMetadata
Azure OpenAI deployment chat/responses URLs OpenAI-compatible usage
OpenRouter /api/v1/chat/completions OpenAI-compatible usage

Larai Tracker stores usage metadata only. It does not persist prompts, completions, raw bodies, authorization headers, or API keys.

๐Ÿ“Š Accessing the Dashboard

Navigate to your application's URL at: https://your-domain.com/larai-tracker

The dashboard features a premium dark-mode interface with:

  • Total Investment: Your overall API spent.
  • Burn Rate: Today's AI cost.
  • Token Metrics: Total computation used.
  • Live Stream: A real-time log of the latest AI calls.

Configuration

Authentication (Singleton Auth)

Larai Tracker uses a simple yet secure singleton authentication system. You can set the password in three ways (ordered by priority):

  1. Database: Change it directly from the Security section in the dashboard settings.
  2. Environment: Set LARAI_TRACKER_PASSWORD in your .env file.
  3. Config: Set it in config/larai-tracker.php.

If no password is set outside local, first setup is disabled unless LARAI_TRACKER_SETUP_TOKEN contains at least 16 characters. Enter that token once on the setup screen, save the password, then remove the setup token from the environment. Login is limited to five attempts per minute per IP.

Pricing, currency, and budgets

All estimated costs and budgets use USD. Unknown models are logged with a null cost, shown as Price unavailable, and excluded from totals and budget alerts. Prices are estimates and never replace provider invoices. Manual model prices take precedence and are not overwritten by catalog sync. See catalog provenance.

Retention

Web requests no longer run cleanup. Set the retention period in Settings and schedule the command in the host application:

use Illuminate\Support\Facades\Schedule;

Schedule::command('larai:cleanup')->daily();

You can also run php artisan larai:cleanup --days=90 --batch=1000 manually.

Upgrading from v1.1.x

composer require gometap/larai-tracker:^1.2
php artisan vendor:publish --tag="larai-tracker-migrations"
php artisan migrate

The upgrade makes cost_usd nullable, adds price provenance and budget-alert idempotency fields, and normalizes the old display-only currency setting to USD. Existing logs and manual prices remain unchanged. Replace any GET logout links with the package's POST form if you published custom views, and schedule larai:cleanup if retention is enabled.

๐Ÿงช Testing

The package includes a comprehensive test suite powered by Pest.

composer test
composer format:check
composer analyse

Contributing

Please see CONTRIBUTING for details.

Credits

License

The Apache License 2.0. Please see License File for more information.