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.1.0(3w ago)0277↓94%LGPL-2.1-onlyPHPPHP &gt;=8.2

Since Feb 11Pushed 3w 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 1w ago

READMEChangelog (7)Dependencies (2)Versions (7)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

45

—

FairBetter than 91% of packages

Maintenance94

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.7% 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 ~106 days

Recently: every ~132 days

Total

6

Last Release

25d 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 (22 commits)")[![mend-bolt-for-github[bot]](https://avatars.githubusercontent.com/in/16809?v=4)](https://github.com/mend-bolt-for-github[bot] "mend-bolt-for-github[bot] (1 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.2k555.0M2.8k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k832.6k55](/packages/neuron-core-neuron-ai)[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M188](/packages/spatie-laravel-health)[spatie/flare-client-php

Send PHP errors to Flare

178166.2M24](/packages/spatie-flare-client-php)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.3M49](/packages/tencentcloud-tencentcloud-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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