PHP code example of hanshs474 / kavel

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

    

hanshs474 / kavel example snippets


$kavel = new Kavel\Kavel();

$img = $kavel->generate(
    'matte black ceramic mug on pale oak, soft window light from the left, shallow depth of field',
    '16:9',
);
echo $img->url; // https://cdn.kavel.ai/uploads/kie/image/....webp

$edited = $kavel->edit($img->url, 'place the mug on a white marble surface');

$kavel = new Kavel\Kavel(apiKey: getenv('KAVEL_API_KEY'), model: 'gpt-image-2');
$img = $kavel->generate($prompt);
bash
php tests/run.php