Download the PHP package hikuroshi/rate-budget without Composer

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

hikuroshi/rate-budget

A multi-key quota decision engine for RPM, TPM, and RPD-aware routing.

hikuroshi/rate-budget selects an active key within a scope such as a tenant, workspace, project, user, or guild. Each key has independent RPM, TPM, and RPD limits, so your application can safely move to another key when one key is cooling down, under token pressure, or near its daily quota.

The package is lightweight, dependency-free, and storage adapter friendly. Your application owns the state; hikuroshi/rate-budget only computes quota decisions and records reservations through the configured adapter.

Install

Core Algorithm

RPM: spacing-based cooldown.

TPM: sliding 60-second token window.

RPD: daily threshold guard.

Quick Start

Use a single key when you do not need key rotation yet.

Use multiple keys with priority when you want automatic key rotation.

API

new Quota($options = [])

Constructor options:

reserve($scope, $keyOrKeys, $req = null)

Selects the best key and immediately creates a reservation for RPM, TPM, and RPD accounting. $keyOrKeys can be a single key array/object or a list of keys.

Successful result:

Blocked result:

waitMs is null when the request cannot be handled by any key, for example when the estimated token count is larger than every key's TPM limit.

commit($hold, $usage = [])

Completes a reservation after the request has actually consumed provider quota.

rollback($hold)

Cancels a reservation when a request was not sent or failed before provider quota was consumed.

check($scope, $keyOrKeys, $req = null)

Runs a dry check to see which key would be selected without creating a reservation.

check() still touches storage to normalize scope/key state and prune old token hits, but it does not create a hold or consume quota.

Key Shape

Fields:

Extra fields are preserved on the selected key, so you can attach provider names, encrypted key references, model names, or metadata.

Selection Rules

  1. Disabled keys are skipped.
  2. A key must pass RPD threshold, RPM cooldown, and TPM window checks.
  3. Among allowed keys, the highest priority wins.
  4. Ties prefer lower token pressure, then lower daily pressure, then key id.
  5. If no key is allowed, the result returns the shortest useful waitMs.

Storage Adapter

MemoryStore is useful for one process. For multi-instance systems, implement QuotaStore with Redis, SQL, DynamoDB, Laravel cache with locks, or any transactional storage.

The mutate callback must run atomically per scope. That keeps reservations safe when many workers route requests at the same time.

Helpers

Exports:

Build and Test


All versions of rate-budget with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
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 hikuroshi/rate-budget contains the following files

Loading the files please wait ...