1. Go to this page and download the library: Download cattyneo/laravel-genai 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/ */
use CattyNeo\LaravelGenAI\Facades\GenAI;
// Simple question
$response = GenAI::ask('Hello, how are you?');
// With specific provider and model
$response = GenAI::provider('openai')
->model('gpt-4o')
->ask('Explain Laravel in simple terms');
// Using presets
$response = GenAI::preset('blog')
->prompt('Write about AI and Laravel')
->request();
// With custom options
$response = GenAI::provider('claude')
->model('claude-3-opus')
->options([
'temperature' => 0.7,
'max_tokens' => 1000,
])
->ask('Create a detailed project plan');
// With streaming
$response = GenAI::provider('openai')
->options(['stream' => true])
->ask('Generate a long story')
->stream();
// Async requests
$response = GenAI::preset('analysis')
->options(['async' => true])
->prompt('Analyze this data: ' . $data)
->request();
// In your tests
GenAI::fake([
'ask' => 'Mocked response',
'request' => 'Another mock',
]);
// Assert requests
GenAI::assertRequested('ask', 'Hello');
bash
php artisan genai:install
bash
# Install the package
php artisan genai:install
# Install with options
php artisan genai:install --force --skip-migration
bash
# Test all providers
php artisan genai:test
# Test specific provider
php artisan genai:test --provider=openai
# Test with custom prompt
php artisan genai:test --prompt="Hello, world!" --provider=claude
bash
# Show usage statistics
php artisan genai:stats
# Statistics for specific period
php artisan genai:stats --days=30
# Detailed breakdown
php artisan genai:stats --detailed --provider=openai
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.