Image
Generate images from text
Nano Banana
namespace App\Neuron;
use NeuronAI\Agent\Agent;
use NeuronAI\Chat\Messages\UserMessage;
use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Providers\Gemini\Gemini;
class MyAgent extends Agent
{
protected function provider(): AIProviderInterface
{
return new Gemini(
key: 'GEMINI_API_KEY',
model: 'gemini-2.5-flash-image',
);
}
}
// Run the agent
$message = MyAgent::make()
->chat(new UserMessage("Generate an image of a venue hosting the best PHP conference!"))
->getMessage();
// Retrieve the image part of the message (it's in base64 format)
$imageBase64 = $message->getImage()->getContent();
// Save the audio file
file_put_contents(__DIR__.'/assets/cover.png', base64_decode($imageBase64));OpenAIImage
As an Agent provider
Direct use
Last updated