Download the PHP package jpsantosbembe/laravel-ai-budget without Composer

On this page you can find all versions of the php package jpsantosbembe/laravel-ai-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 laravel-ai-budget

Laravel AI Budget

tests static analysis

Cost-governed LLM execution for Laravel.

Most LLM packages are transport wrappers: they hand you a client and leave the bill to you. This one starts from the other end. You describe a task once as a profile — model, fallback, limits, output schema, retries and a spend ceiling — and every run through that profile is checked against the ceiling before a single token is spent, validated on the way out, and written to a usage log with its real cost.

It was extracted from a production application where it has been running since April 2026.

What it actually does

Spend ceiling The estimated cost of a run is computed from the price table and compared against the profile's max_cost_per_run. Over the line, BudgetExceededException is thrown before the provider is called.
Retries and fallback retries attempts per model; once they are exhausted the profile's fallback_model takes over — and the result tells you whether it did.
Schema validation When a profile declares a json_schema, the output is decoded (markdown fences and all), validated, and re-asked once if it does not match.
Honest accounting Every call lands in ai_usage_logs with tokens, latency, and cost in USD and in your local currency — including the calls that failed validation, because the provider billed for those too.
Pipelines Multi-stage map/single workflows over job batches, with the ceiling applied to the whole pipeline, per-item failure isolation and retry of only what failed.

Installation

Publish the configuration when you want to own the price table or point at a live FX rate:

Getting started

Store a credential and define a profile:

Run it:

Ask what it would cost before committing to it:

Currency

Provider prices are quoted in USD; budgets are usually not. Set your currency and how to convert:

max_cost_per_run and cost_local are then expressed in that currency, and cost_usd is always kept alongside it.

Pipelines

A pipeline is an ordered list of stages. map stages fan out — one queued job per item — and single stages run once, typically to synthesise what the previous stages produced.

Progress is reported through the PipelineProgress event. It is a plain event, not a broadcast one: the durable state lives in the database and progressSnapshot() rebuilds the identical payload over HTTP, so a websocket is an optimisation rather than a requirement. Pipelines need Laravel's job_batches table (php artisan queue:batches-table).

Providers

OpenRouterTransport ships with the package. Add your own by implementing ChatTransport and registering it:

The transport is selected per credential through its provider column, so different profiles can run against different providers in the same application.

An implementation must translate provider failures into the package's exceptions — InvalidCredentialException for a rejected key, and RateLimitedException when throttled — so retries and fallback behave the same everywhere.

Schema validation

The bundled validator supports the subset of JSON Schema that structured LLM output actually uses: type, required, properties, items and enum, recursively. That keeps the package dependency-free. If you need the full spec, implement SchemaValidator around a real validator and point ai-budget.schema_validator at it.

Behaviour worth knowing

A rejected API key disables the credential. A 401 means every later run would fail the same way, so the credential is switched off and the exception propagates once, instead of silently burning through your queue.

A failed re-ask is still recorded. If the output fails the schema twice, the tokens from both calls are written to the usage log before SchemaMismatchException is thrown. A run that vanished from the log would be exactly the run you most need to see: the model returning garbage while the bill climbs.

Unknown models are expensive by default. A model missing from the price table falls back to the configured generic price rather than zero, because a zero would quietly disable the ceiling for the models nobody registered.

Requirements

PHP 8.3+ and Laravel 12, on PostgreSQL, MySQL or SQLite.

Laravel 11 is deliberately not supported: as of this release every 11.x release carries an unresolved security advisory, so Composer refuses to install it under its default policy. Supporting a line you cannot install cleanly is a promise the package cannot keep.

Testing

License

MIT. See LICENSE.md.


All versions of laravel-ai-budget with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/bus Version ^12.0
illuminate/database Version ^12.0
illuminate/http Version ^12.0
illuminate/support Version ^12.0
psr/log Version ^3.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 jpsantosbembe/laravel-ai-budget contains the following files

Loading the files please wait ...