Skip to main content

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 configuration

Built-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:
The run() method returns a fluent executor - chain your configuration and call go() to execute!

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:
Available sizes depend on your provider:

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

The ImageResponse 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

The then() callback runs after generation completes - use it to store images or trigger notifications. The callback must be serializable for queue processing.

Listening for Completion

Listen for media generation events:

Using with LLM Agents

Allow your LLM agents to generate images using the DelegateToMediaAgentTool:

Setup

Quick Setup with Factory Method

How It Works

When the LLM decides to generate an image, it calls the generate_image tool with these parameters:
The tool automatically:
  1. Executes the ImageAgent with the provided parameters
  2. Stores the generated image
  3. 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

Google

  • 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