PHPackages                             token27/nexus-ai-tracking - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. token27/nexus-ai-tracking

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

token27/nexus-ai-tracking
=========================

Lightweight execution store (JSONL / SQLite / InMemory) for tracking executions with cost, latency and token metrics.

v1.0.0(2w ago)014↓100%MITPHPPHP ^8.3CI passing

Since May 21Pushed 2w agoCompare

[ Source](https://github.com/token27/nexus-ai-tracking)[ Packagist](https://packagist.org/packages/token27/nexus-ai-tracking)[ Docs](https://github.com/token27/nexus-ai-tracking)[ RSS](/packages/token27-nexus-ai-tracking/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

NexusAI Tracking
================

[](#nexusai-tracking)

[![CI](https://github.com/token27/nexus-ai-tracking/actions/workflows/ci.yml/badge.svg)](https://github.com/token27/nexus-ai-tracking/actions)[![PHPStan Level 8](https://camo.githubusercontent.com/412205ac46adf8d1c9329cfcacca7da2697c664b7f1ffd18076a4a17c1e9de6d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d316636666562)](https://phpstan.org/)[![Latest Version](https://camo.githubusercontent.com/e186e56b8172672e1d847e3825efe2f38f9ceb7dc3913b12dbe5ce1118ecdf06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f6b656e32372f6e657875732d61692d747261636b696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/token27/nexus-ai-tracking)[![PHP 8.3+](https://camo.githubusercontent.com/38027453aeb7eb818641c9de8f82b7624c3558d92634f1946edc715c3ddf8956/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d3737374242343f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://php.net)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)[![Tests](https://camo.githubusercontent.com/4f9ce0e58cf097d38316fe70fd3464a7cc37420a02fff353a0e69e031d62a123/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54657374732d373625323070617373696e672d627269676874677265656e)](#testing)

A **standalone, zero-dependency** PHP 8.3+ execution store for tracking AI pipeline runs with cost, latency and token metrics. Supports JSONL, SQLite and InMemory backends — usable in any framework or domain.

Why nexus-ai-tracking?
----------------------

[](#why-nexus-ai-tracking)

When building AI pipelines (content generation, code assistants, data processors…) you need to answer:

- **How much did that run cost?**
- **Which model is slowest?**
- **Which prompt version performs best?**
- **What failed and when?**

`nexus-ai-tracking` gives you append-only, immutable event recording with zero configuration and three backends that suit any environment — from a local script to a production cluster.

Features
--------

[](#features)

- **Append-only event store** — immutable audit trail, no updates ever
- **3 backends** — JSONL files, SQLite, InMemory (testing)
- **Thread-safe writes** — `flock()` file locking on JSONL, transactions on SQLite
- **Auto-schema** — SQLite creates its own schema on first use
- **Daily file partitioning** — JSONL files split by day, automatic date-range optimization
- **Flexible aggregate queries** — filter by model, content type, language, date range, event type
- **Run projections** — grouped `RunSummary` with status, cost, tokens, latency, step count
- **Extensible** — add new backends by implementing one interface
- **Zero external dependencies** — only `ext-json` required

Installation
------------

[](#installation)

```
composer require token27/nexus-ai-tracking
```

**Requires:** PHP 8.3+ · `ext-json` · `ext-pdo_sqlite` *(SQLite backend only)*

Quick Start
-----------

[](#quick-start)

```
use Token27\NexusAI\Tracking\Engine\TrackingEngine;
use Token27\NexusAI\Tracking\Enum\ExecutionEventType;

// 1. Initialize tracker
$tracker = TrackingEngine::using('sqlite', '/var/data/tracking.sqlite');

// 2. Fluent Event Recording
$tracker
    ->track(ExecutionEventType::PROMPT_EXECUTED, 'run-abc123')
    ->withModel('gpt-4o')
    ->withTokens(1500)
    ->withCostUsd(0.045)
    ->withLatencyMs(850)
    ->with('prompt', [
        'source' => 'seo/article',
        'version' => 'v2.1',
        'content' => 'Prompt content generated here',
    ])
    ->with('metadata', [
        'title' => 'Article title seo optimized',
        'content' => 'Article content seo optimized',
        'created' => '2026-05-21'
    ])
    ->record();

// 3. Fluent Querying
$metrics = $tracker->query()
    ->withData('model', 'gpt-4o')
    ->withLastPeriod('-7 days')
    ->metrics();

echo "Total cost last 7 days: \${$metrics->totalCostUsd}\n";
echo "Total tokens: {$metrics->totalTokens}\n";
echo "Avg latency: {$metrics->avgLatencyMs}ms\n";
```

Backends
--------

[](#backends)

BackendDriver keyBest for`JsonFileExecutionStore``jsonfile`Default — zero config, portable, daily JSONL files`SqliteExecutionStore``sqlite`Aggregate queries, production apps`InMemoryExecutionStore``memory`Unit tests — zero I/ODocumentation
-------------

[](#documentation)

Full documentation is available in the [`docs/`](docs/) directory:

- [Docs Guide](docs/README.md)
- [Installation &amp; Setup](docs/installation.md)
- [Recording Events](docs/recording-events.md)
- [Reading Events](docs/reading-events.md)
- [Backends](docs/backends.md)
- [Architecture](docs/architecture.md)
- [Testing](docs/testing.md)
- [Contributing &amp; Extending](docs/contributing.md)

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- `ext-json` (bundled with PHP)
- `ext-pdo` + `ext-pdo_sqlite` *(only for SQLite backend)*

Contributing
------------

[](#contributing)

Please see [docs/contributing.md](docs/contributing.md) for details on adding new backends, event types, and development standards.

License
-------

[](#license)

MIT. Please see [LICENSE](LICENSE) for more information.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance96

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

19d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/78189912?v=4)[Token27](/maintainers/token27)[@token27](https://github.com/token27)

---

Top Contributors

[![token27](https://avatars.githubusercontent.com/u/78189912?v=4)](https://github.com/token27 "token27 (1 commits)")

---

Tags

aitrackingMetricscost-trackingexecution-storeexecution-tracking

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/token27-nexus-ai-tracking/health.svg)

```
[![Health](https://phpackages.com/badges/token27-nexus-ai-tracking/health.svg)](https://phpackages.com/packages/token27-nexus-ai-tracking)
```

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.5M28](/packages/rubix-ml)[codewithkyrian/transformers

State-of-the-art Machine Learning for PHP. Run Transformers in PHP

761254.8k7](/packages/codewithkyrian-transformers)[maestroerror/laragent

Power of AI Agents in your Laravel project

638142.5k](/packages/maestroerror-laragent)[zumba/amplitude-php

PHP SDK for Amplitude

4010.1M5](/packages/zumba-amplitude-php)[symfony/ai-platform

PHP library for interacting with AI platform provider.

521.2M214](/packages/symfony-ai-platform)[symfony/ai-agent

PHP library for building agentic applications.

31746.8k81](/packages/symfony-ai-agent)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
