1. Go to this page and download the library: Download fiachehr/laravel-ai-gateway library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fiachehr / laravel-ai-gateway example snippets
use Fiachehr\AiGateway\Facades\AI;
$response = AI::provider('openai')
->model('gpt-5-mini')
->systemPrompt('You are a concise technical assistant.')
->userPrompt('Write a short welcome message for new users.')
->send();
$text = $response->responseText;
$response = AI::provider('gemini')
->model('gemini-2.5-flash')
->systemPrompt('Respond in Persian.')
->prompt('Summarize this text.')
->options(['generationConfig' => ['temperature' => 0.2]])
->metadata(['source' => 'admin-panel'])
->send();
use Fiachehr\AiGateway\Services\AIManager;
$response = app(AIManager::class)->send(
provider: 'deepseek',
model: 'deepseek-chat',
prompt: 'Explain SOLID briefly.',
systemPrompt: 'Keep it short and practical.',
options: [],
metadata: ['request_id' => request()->id()]
);
use Fiachehr\AiGateway\Facades\AI;
$models = AI::listModels('openai');