1. Go to this page and download the library: Download noxsi/laravel-gemininano 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 Noxsi\GeminiNano\Facades\GeminiNano; // Facade alias
// Generate an image from a text prompt
$response = GeminiNano::images()->generate(
'Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme'
);
// Depending on config:
// - GEMINI_NANO_STORE=true -> result() returns a URL (stored via filesystem)
// - GEMINI_NANO_STORE=false -> result() returns a base64 string
$result = $response->result();
return response()->json([
'image' => $result,
]);
use Noxsi\GeminiNano\Client;
class BananaController
{
public function __construct(
private Client $gemini,
) {}
public function __invoke()
{
$response = $this->gemini
->images()
->generate('A futuristic nano banana in a Gemini-themed lab');
return [
'image' => $response->result(),
];
}
}
use Noxsi\GeminiNano\Facades\GeminiNano;
$imagePath = storage_path('app/public/example.jpg');
$response = GeminiNano::images()->generate(
prompt: 'Caption this image.',
imagePath: $imagePath,
imageMimeType: 'image/jpeg', // optional, will be auto-detected if null
);
$result = $response->result(); // URL or base64 depending on config