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)0270↓92.2%[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 today

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

31

—

LowBetter than 66% of packages

Maintenance40

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

508d 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

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[spatie/flare-client-php

Send PHP errors to Flare

177161.5M23](/packages/spatie-flare-client-php)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

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