PHPackages                             llmcosts/llm-cost-logger - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. llmcosts/llm-cost-logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

llmcosts/llm-cost-logger
========================

Reference code to log LLM Call metadata to the llmcosts.fyi service

1.0.5(1y ago)0230↓37.5%[1 PRs](https://github.com/yourpropertyexpert/LLMCostsLoggingClassesPHP/pulls)LGPL-2.1-onlyPHPPHP &gt;=8.2

Since Feb 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/yourpropertyexpert/LLMCostsLoggingClassesPHP)[ Packagist](https://packagist.org/packages/llmcosts/llm-cost-logger)[ RSS](/packages/llmcosts-llm-cost-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (1)Versions (6)Used By (0)

LLMCostsLoggingClasses
======================

[](#llmcostsloggingclasses)

This repo contains the source code for the PHP class you might need to log into llmcosts.fyi

We wouldn't normally expect you to need to install from source, and this code is typically very simple

You need an API key from llmcosts.fyi. Reference code, prepopulated with your API key is available to users of that site, but the quick version is here.

For use with other clients, you will also need to replace the name "OpenAI" in the -&gt;logCall function with a provider supported by the service.

### Installation

[](#installation)

The best way is to install via Composer, by adding to the "require" section of your composer.json file

```
{... other requirements ...}
"llmcosts/llm-cost-logger": "1.0.0"

```

### Using with the OpenAI client:

[](#using-with-the-openai-client)

```
/**
 * Your existing code
 */
$client = \OpenAI::Client("");
$result = $client->chat()->create([
    'model' => self::MODEL,
    'messages' => [
        ['role' => 'user', 'content' => ''],
    ],
]);
$resultArray = $result->toArray();

/**
 * The two lines you need to add logging
 * The  can be anything, but see above
 */
+ $costLogger = new LLMCostLogger("{{key}}");
+ $costLogger->logCall("OpenAI", $resultArray);
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance43

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Every ~0 days

Total

5

Last Release

456d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5714a2749d7e1402ea4197471647477071643b7ea984567104b764b536af64a2?d=identicon)[yourpropertyexpert](/maintainers/yourpropertyexpert)

---

Top Contributors

[![yourpropertyexpert](https://avatars.githubusercontent.com/u/16901176?v=4)](https://github.com/yourpropertyexpert "yourpropertyexpert (19 commits)")

### Embed Badge

![Health badge](/badges/llmcosts-llm-cost-logger/health.svg)

```
[![Health](https://phpackages.com/badges/llmcosts-llm-cost-logger/health.svg)](https://phpackages.com/packages/llmcosts-llm-cost-logger)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[larabug/larabug

Laravel 6.x/7.x/8.x/9.x/10.x/11.x/12.x/13.x bug notifier

299549.3k1](/packages/larabug-larabug)[honeybadger-io/honeybadger-php

Honeybadger PHP library

381.5M4](/packages/honeybadger-io-honeybadger-php)

PHPackages © 2026

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