PHP code example of runapi-ai / nano-banana
1. Go to this page and download the library: Download runapi-ai/nano-banana 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/ */
runapi-ai / nano-banana example snippets
unApi\NanoBanana\NanoBananaClient;
$client = new NanoBananaClient(); // reads RUNAPI_API_KEY
$editImageTask = $client->editImage->create([
'model' => 'nano-banana-2-lite',
'aspect_ratio' => '1:1',
'output_format' => 'png',
'prompt' => 'Make it golden hour',
'source_image_urls' => ['https://cdn.runapi.ai/public/samples/image.jpg'],
]);
$task = $client->textToImage->create([
'model' => 'nano-banana',
'aspect_ratio' => '1:1',
'output_format' => 'png',
'output_resolution' => '1k',
'prompt' => 'A precise product render on white marble',
'reference_image_urls' => ['https://cdn.runapi.ai/public/samples/image.jpg'],
]);
$status = $client->textToImage->get($task->id);
$result = $client->textToImage->run([
'model' => 'nano-banana',
'aspect_ratio' => '1:1',
'output_format' => 'png',
'output_resolution' => '1k',
'prompt' => 'A serene mountain lake at dawn',
'reference_image_urls' => ['https://cdn.runapi.ai/public/samples/image.jpg'],
]);
echo $result->images[0]->url . PHP_EOL;