PHP code example of openbackend / laravel-ai-image-generator

1. Go to this page and download the library: Download openbackend/laravel-ai-image-generator 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/ */

    

openbackend / laravel-ai-image-generator example snippets


use OpenBackend\AiImageGenerator\Facades\AIImageGenerator;

// Generate an image with default settings
$generation = AIImageGenerator::generate('A beautiful sunset over mountains');

echo $generation->url; // URL to the generated image
echo $generation->file_path; // Local file path (if auto-download enabled)

// Generate with custom options
$generation = AIImageGenerator::generate('A futuristic city', [
    'size' => '1792x1024',
    'quality' => 'hd',
    'style' => 'natural',
    'model' => 'dall-e-3'
]);

// Use a specific provider
$generation = AIImageGenerator::provider('stability')
    ->generate('A magical forest', [
        'width' => 1024,
        'height' => 1024,
        'steps' => 50,
        'cfg_scale' => 7
    ]);

// Async generation (queued)
$generation = AIImageGenerator::generateAsync('A space station');
bash
php artisan vendor:publish --provider="OpenBackend\AiImageGenerator\AiImageGeneratorServiceProvider" --tag="ai-image-generator-config"
bash
php artisan vendor:publish --provider="OpenBackend\AiImageGenerator\AiImageGeneratorServiceProvider" --tag="ai-image-generator-migrations"
php artisan migrate