Download the PHP package boriskwemo/llm-ledger without Composer

On this page you can find all versions of the php package boriskwemo/llm-ledger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package llm-ledger

LLM Ledger - PHP LLM Cost Tracking & Multi-Provider AI Gateway

Track, analyze and control your LLM spend from one clean PHP API - compatible with OpenAI, Anthropic, Google Gemini, Mistral, DeepSeek, Qwen, Kimi, GLM, Grok and any OpenAI-compatible endpoint. Works natively with Symfony 8 and Laravel, installs from Composer, and ships with a customizable cost dashboard, a deprecation-aware model catalog and batch processing - all under the MIT license.

Every call - tokens, reasoning tokens, latency, model, provider and dollar cost - is recorded automatically and visualized in a dashboard. No more guessing what AI actually costs you.


Table of contents

  1. Why LLM Ledger?
  2. Features
  3. Who is it for?
  4. How it compares
  5. Requirements
  6. Installation
  7. Quickstart
  8. Configuration
  9. Model registry & deprecation
  10. Thinking / reasoning tokens
  11. Batch processing
  12. API key handling
  13. Symfony 8 integration
  14. Laravel integration
  15. CLI
  16. Model coverage
  17. Architecture
  18. Testing
  19. Contributing
  20. Security
  21. License

Why LLM Ledger?

Modern apps rarely use one AI provider. They use four or five - a frontier model from OpenAI, Claude for coding, Gemini for long context, DeepSeek or Qwen when cost matters, Mistral for EU data residency. That fragmentation creates three real problems:

Pain point What you hit today What LLM Ledger does
N vendor SDKs A different client, auth, and response shape for every provider One chat() / complete() / batch() API across 19 providers
Invisible spend Reasoning/thinking tokens and cache reads silently change your bill Normalizes and stores reasoning_tokens, cache reads/writes, finish reason and tool calls
No oversight You find out the bill at the end of the month Per-call cost, per-model/per-provider/per-day aggregates, dashboard + CLI
Surprise deprecations A model disappears and your code breaks A deprecation-aware model registry (superseded_by, date, note)

The result: one dependency instead of five, and a complete, queryable audit trail of your AI usage and cost - for free, open-source, without locking you into a gateway or a hosted dashboard.

Features

Who is it for?

How it compares

Raw vendor SDKs Generic HTTP client LLM Ledger
Multi-provider, one API ❌ one SDK per vendor ⚠️ you wire each one ✅ 19 providers, one API
Automatic cost tracking ❌ manual math ✅ + dashboard & CLI
Reasoning/thinking token visibility ⚠️ vendor-specific parsing ✅ normalized
Batch across providers ❌ per-SDK ✅ one batch()
Model deprecation awareness ✅ built-in registry
Symfony 8 & Laravel support DIY DIY ✅ bundle + provider + facade
Open source / self-hosted - - ✅ MIT, data stays with you

Requirements

Installation

Quickstart (plain PHP)

Structured conversation & multimodal content

Configuration (llm.yaml)

Every provider's base_url and protocol default come from the bundled registry; api_key is the only thing you normally add.

Model registry & deprecation

The catalog lives in config/models.yaml - a readable, editable snapshot you can copy and point at with models_file. Each entry carries a description and lifecycle metadata:

Inspect it programmatically:

Pricing is a bundled snapshot. Providers change prices often - treat it as a starting point and override in your own YAML (or via models_file).

Tracking thinking / reasoning tokens

Every result exposes the full picture, normalized across providers:

Where each number comes from (verified against vendor specs):

Provider Reasoning tokens Reasoning content Cached tokens
OpenAI-compatible usage.completion_tokens_details.reasoning_tokens message.reasoning_content (DeepSeek/Qwen/Kimi/GLM) usage.prompt_tokens_details.cached_tokens
Anthropic included in usage.output_tokens (no split) content[].type == "thinking" blocks usage.cache_read_input_tokens / cache_creation_input_tokens
Google Gemini usageMetadata.thoughtsTokenCount parts[].thought == true usageMetadata.cachedContentTokenCount

All of this is persisted (tokens, reasoning text, response text, finish reason, tool calls) - set tracking.store_content: false to keep only the token/cost numbers.

Batch processing

Supported backends:

Each successful item is recorded to the tracker with its custom_id. Use $llm->pollBatch($provider, $id) to resume polling a job without recreating it.

API key handling

Keys are never persisted, never logged, and never stored in the tracking database:

Symfony 8 integration

  1. Register the bundle in config/bundles.php:

  2. Configure it (config/packages/llm_cost_tracker.yaml):

  3. Import the routes (config/routes/llm_cost_tracker.yaml):

  4. Use the autowired service:

Open /llm for the dashboard and /llm/models for the model catalog. To customize the UI, copy Resources/views into templates/bundles/LlmCostTrackerBundle/ and edit - Twig resolution gives your templates priority.

Laravel integration

The package auto-registers via Composer (extra.laravel.providers). Publish config, migration and views:

Configure in .env:

Use the facade:

The dashboard is served at /llm (configurable via llm-cost-tracker.dashboard.route_prefix). Views are published to resources/views/vendor/llm-cost-tracker for customization.

CLI

Standalone dashboard

examples/dashboard.php renders a self-contained HTML dashboard with zero framework dependencies - useful as a reference or for a quick internal tool.

Model coverage

The bundled registry (compiled from vendor documentation, June-Aug 2026) covers, among others:

Region Providers
🇺🇸 US / Global OpenAI, Anthropic, Google, xAI, Groq, Cohere, Meta (Llama), OpenRouter
🇫🇷 France Mistral AI, Kyutai (Moshi), LightOn (Alfred)
🇨🇳 China DeepSeek, Alibaba Qwen, Moonshot Kimi, Zhipu GLM, Baidu Ernie, MiniMax, ByteDance Doubao, Tencent Hunyuan

Sources used for the snapshot: LLM API pricing comparison, Mistral API pricing, Chinese LLM price war 2026, OpenAI API pricing, Claude API pricing, Gemini API pricing, xAI Grok pricing, Qwen API pricing, DeepSeek API pricing, and GLM-5.2 vs Kimi K3.

Architecture

Token counts come from each provider's usage field (authoritative). When a provider omits usage, a ~4 chars/token heuristic fills the gap so tracking never silently drops a call.

Testing

Contributing

Contributions are welcome - code, docs, tests, or model/pricing updates. See CONTRIBUTING.md for setup, coding standards, and the pull-request process.

Security

To report a vulnerability privately (not in a public issue), see SECURITY.md. Your API keys are never persisted or logged; read the file for key-handling best practices.

License

MIT - free to use, modify and ship in commercial projects. See LICENSE.


All versions of llm-ledger with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-json Version *
ext-pdo Version *
nyholm/psr7 Version ^1.8
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
symfony/http-client Version ^6.4 || ^7.0 || ^8.0
symfony/yaml Version ^6.4 || ^7.0 || ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package boriskwemo/llm-ledger contains the following files

Loading the files please wait ...