PHP code example of omer-hanaraey / laravel-ai-gateway

1. Go to this page and download the library: Download omer-hanaraey/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/ */

    

omer-hanaraey / laravel-ai-gateway example snippets


use LaravelAiGateway\Ai\Facades\Ai;

$response = Ai::chat([
    ['role' => 'system', 'content' => 'You are a helpful assistant'],
    ['role' => 'user', 'content' => 'Tell me a joke about Laravel']
]);

echo $response->getContent();

$response = Ai::driver('claude')
    ->withModel('claude-3-haiku-20240307')
    ->chat([...]);
bash
php artisan vendor:publish --tag=ai-bridge-config