Download the PHP package tokentifyai/usagemeter without Composer

On this page you can find all versions of the php package tokentifyai/usagemeter. 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 usagemeter

Tokentify UsageMeter (PHP)

Out-of-band AI API usage metering for PHP. After setup, call your provider’s HTTP API yourself, then record usage with Meter::track() (the PHP SDK does not auto-wrap HTTP clients).

Install

Optional: load .env in development (recommended):

Setup

1. Environment (API key is global)

Copy .env.example to .env. The API key lives only in .env (or your deployment environment)—never in init() code.

2. Initialize

Call When to use
Tokentify::init(..., ['verify_connection' => true, 'verify_api_key' => true]) First run; verifies collector + USAGEMETER_API_KEY from .env
Tokentify::init(...) Same; control verify_connection / verify_api_key

Init parameters (API key is not accepted):

Parameter Source
bucket First argument (value of USAGEMETER_BUCKET) or USAGEMETER_BUCKET in .env
tracking_fields Second argument (must include account_id, user_id)
app_name Third-argument merge array or USAGEMETER_APP_NAME in .env
environment Merge array or USAGEMETER_ENVIRONMENT in .env (default production)
load_env_file Default true when phpdotenv is installed — loads .env before reading env vars
verify_connection Default false (set true for first-time setup)
verify_api_key Default true

Call init() before provider HTTP calls and Meter::track() events.

Agent tool tracking

After your app executes a tool (any provider / agent framework), call Meter::trackTool() once:

Provider APIs expose tool-call data in different places (response content vs client-side MCP loops; never in billing usage). See the provider research matrix before adding auto-capture.

Token breakdown (v0.4.0)

The SDK extracts input, output, cache read, and cache write tokens from provider JSON via UsageParser.

Recommended — trackFromResponse

Alternative — track(['response_body' => ...])

Field mapping

Ingest field Anthropic source OpenAI source
input_tokens usage.input_tokens prompt_tokens − cached_tokens
output_tokens usage.output_tokens usage.completion_tokens
cache_read_tokens usage.cache_read_input_tokens usage.prompt_tokens_details.cached_tokens
cache_write_tokens usage.cache_creation_input_tokens

Anti-pattern

3. Launch (v0.4.0)

.env (USAGEMETER_API_KEY + USAGEMETER_BUCKET):

app.php:

4. Develop from this repo

Quick init check:


All versions of usagemeter with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-json Version *
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 tokentifyai/usagemeter contains the following files

Loading the files please wait ...