What is ImageAgent?
ImageAgent is a specialized media agent that generates images from text descriptions. It integrates with providers like OpenAI (DALL-E) and Google (Imagen) through Prism PHP, offering a fluent API for configuration, built-in storage, and queue support.Multi-Provider
Works with OpenAI DALL-E, Google Imagen, and other image generation models
Fluent API
Chain methods like
size(), quality(), and style() for clean configurationBuilt-in Storage
Store generated images directly to Laravel’s filesystem with
store() and storeAs()Queue Support
Process image generation asynchronously with Laravel queues
Quick Start
Generate an image with just a few lines of code:Basic Usage
Simple Generation
Storing Images
Images can be stored to Laravel’s filesystem:Images are stored in the
vizra-adk/generated/images/ directory by default. Configure this in your vizra-adk.php config file.Auto-Store on Generation
Chain storage directly in the fluent API:Configuration Options
Image Size
Set dimensions using preset methods or custom sizes:Quality
Control the quality level (OpenAI-specific):Style
Set the visual style (DALL-E 3 specific):Provider & Model
Override the default provider and model:Complete Configuration Example
ImageResponse Class
TheImageResponse object provides access to all image data and metadata:
Accessing Image Data
Metadata
Serialization
Async & Queue Processing
For long-running generations, use Laravel queues:Basic Async
Queue Configuration
Listening for Completion
Listen for media generation events:Using with LLM Agents
Allow your LLM agents to generate images using theDelegateToMediaAgentTool:
Setup
Quick Setup with Factory Method
How It Works
When the LLM decides to generate an image, it calls thegenerate_image tool with these parameters:
- Executes the ImageAgent with the provided parameters
- Stores the generated image
- Returns the URL and path to the LLM
Context & User Tracking
Associate generations with users and sessions:Configuration Reference
Environment Variables
Config File
config/vizra-adk.php
Supported Providers & Models
OpenAI
- dall-e-3 - Latest, highest quality
- dall-e-2 - Faster, more sizes
- gpt-image-1 - Newest model
- imagen-3 - High quality generation
- imagen-4 - Latest Imagen model
- gemini-2.0-flash-preview-image-generation
API Reference
ImageAgent Static Methods
MediaAgentExecutor Methods (Fluent API)
ImageResponse Methods
Audio Agent
Generate speech and audio with the AudioAgent
Agent Queuing
Learn more about async agent processing