Download the PHP package 1manfactory/ai-costs without Composer

On this page you can find all versions of the php package 1manfactory/ai-costs. 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 ai-costs

ai-costs

ai-costs is an unofficial PHP library for calculating LLM API costs from usage payloads.

It is designed to stay SDK-agnostic: feed it an OpenAI, Anthropic Claude, or Google Gemini usage payload, or a normalized usage object, and it returns a detailed cost breakdown.

[!WARNING] This library provides estimates only. I do not guarantee the accuracy, completeness, or fitness of the calculated values for any billing purpose. The amounts actually billed by the provider are authoritative and always take precedence.

Units

All calculated cost values are returned as integers in usd_microcent.

Current scope

Installation

Quick start

Included building blocks

Notes

Development

Run the local PHP checks manually with Composer:

The versioned Git hook lives in .githooks/pre-commit and this repository is configured to use it via git config core.hooksPath .githooks.

Every git commit runs composer lint:all; the commit is blocked immediately when one of the checks fails.

Release flow

This repository uses a GitHub Actions workflow at .github/workflows/release-tag.yml to create a new patch tag on every push to main.

That means the publishing path is:

local repository -> GitHub main -> automatic Git tag -> Packagist update

After the repository is submitted once on Packagist, each new Git tag becomes a new Composer-installable package version.

Pricing sources

The bundled pricing catalog is based on official provider docs as of 2026-06-07.

On 2026-06-07, the bundled model prices and OpenAI helper tool charges were re-checked against the official pricing pages linked below. No token-price changes were required for the models currently included in this repository; this update brings the verification date and documentation in sync with that review.

Provider Included model families Billing modes in catalog Last verified
OpenAI gpt-5.5, gpt-5.5-pro, gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, gpt-5.4-pro, gpt-5, gpt-5-mini, gpt-5-nano, gpt-5-pro, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, gpt-4o, gpt-4o-mini, o1, o1-mini, o1-pro, o3, o3-mini, o3-pro, o4-mini, o3-deep-research, o4-mini-deep-research, codex-mini-latest, computer-use-preview, gpt-4-turbo, gpt-4, gpt-3.5-turbo, gpt-3.5-turbo-instruct standard, selected batch, selected flex, selected priority 2026-06-07
Anthropic claude-opus-4-7, claude-sonnet-4-6, claude-haiku-4-5 standard, batch 2026-06-07
Google Gemini gemini-2.5-pro, gemini-2.5-flash, gemini-2.5-flash-lite standard, batch, flex, priority 2026-06-07

All versions of ai-costs with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
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 1manfactory/ai-costs contains the following files

Loading the files please wait ...