Download the PHP package fiachehr/laravel-ai-gateway without Composer

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

Laravel AI Gateway

Latest Version Total Downloads

Unified AI gateway for Laravel: one fluent API for multiple providers, normalized response DTOs, and database logging that never breaks the main request flow.

Table of contents

Documentation

Supported providers

Provider Key Model listing
OpenAI openai Yes
Gemini gemini Yes
DeepSeek deepseek Yes
Claude claude No (throws capability exception)
Ollama ollama Yes

Features

Requirements

Installation

Publish assets and migrate:

The service provider registers automatically. The facade alias is AI → Fiachehr\AiGateway\Facades\AI.

Environment variables

Minimal .env example (adjust per provider you use):

Configuration

After publishing, edit config/aigateway.php. Defaults come from env() as in the block above. Each provider has base_url and usually api_key (Ollama may omit the key on a local install).

Usage

Fluent API (recommended)

prompt() as user message

Service layer

Default provider and model

If you omit provider() or model(), values from config('aigateway.default_provider') and config('aigateway.default_model') are used.

Response object

send() returns Fiachehr\AiGateway\DTOs\AIResponseData (readonly). Common properties:

Property Type Description
responseText string Normalized assistant text
provider string Provider key
model string Model id used
requestPayload array Payload sent to the provider
responsePayload array Raw decoded JSON response
requestId ?string When the API returns one
inputTokens ?int Usage when available
outputTokens ?int Usage when available
totalTokens ?int Usage when available
estimatedCost ?float Reserved; not computed by the package
metadata array Merged metadata from request/response

Use ->toArray() for logging or API responses.

Model listing

Each entry is a ModelData instance with id, provider, name, metadata, and toArray(). For claude, listing throws CapabilityNotSupportedException by design.

Logging

Rows are written to ai_logs (Eloquent: Fiachehr\AiGateway\Models\AILog) with:

If the database write fails, the error is swallowed so your application flow continues.

Error handling

Exception hierarchy (all extend AIException unless noted):

Extending with new providers

  1. Create a class implementing Fiachehr\AiGateway\Contracts\AIProviderContract (send() returns AIResponseData).
  2. Optionally implement Fiachehr\AiGateway\Contracts\ModelListableContract for listModels().
  3. Register the provider key in Fiachehr\AiGateway\Factories\ProviderFactory::make().
  4. Add config under config/aigateway.php providers and document env keys in your README.

Bind the concrete class in AiGatewayServiceProvider if you need container injection.

Testing

From a clone of this repository:

Troubleshooting

Symptom What to check
Class "Fiachehr\AiGateway\Facades\AI" not found Run composer dump-autoload, clear config cache php artisan config:clear.
Migration errors Publish migrations once; avoid duplicate ai_logs table names.
Empty responseText Inspect responsePayload in logs; model or API shape may have changed.
Gemini 404 on model Use full model id as in Google docs (e.g. gemini-2.5-flash).
Claude model list fails Expected: use CapabilityNotSupportedException or call listing only on supported drivers.

Security

Links

License

This package is released under the MIT License.


All versions of laravel-ai-gateway with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.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 fiachehr/laravel-ai-gateway contains the following files

Loading the files please wait ...