Skip to content

Image Generation ​

Iris can generate images from text descriptions using OpenAI's GPT Image model (gpt-image-1.5). Ask for artwork, illustrations, diagrams, or any visual content.

Features ​

  • Text-to-Image: Generate images from natural language
  • Multiple Sizes: Square, landscape, or portrait
  • High Quality: Requests GPT Image's high quality setting
  • Inline Display: Images appear directly in chat
  • Persistent Storage: Images are saved and accessible later

Setup ​

Image generation requires an OpenAI API key. Verify your .env includes:

bash
OPENAI_API_KEY=your-openai-key

That's it -image generation is automatically available. The generate_image tool uses the same API key configured for embeddings.

Usage ​

Ask Iris to create an image:

You: "Create an image of a sunset over mountains"

Iris: [generates and displays image]

"Here's a sunset over mountains, with the last light on the snowy peaks."

Being Specific ​

The more detail you provide, the better the results:

You: "Generate a watercolor painting of a cozy coffee shop with warm lighting, wooden furniture, plants on the windowsill, and a cat sleeping on a chair"

Style Guidance ​

Specify artistic styles to get the look you want:

StyleExample prompt
Minimalist"A minimalist line art portrait of a woman with flowing hair"
Pixel art"A pixel art scene of a forest at night with fireflies"
Photorealistic"A photorealistic image of a modern kitchen with marble countertops"
Watercolor"A watercolor painting of a sailboat at sunset"
Oil painting"An oil painting of a mountain landscape in the style of the Hudson River School"
Digital art"Digital art of a futuristic cityscape with neon lights"

Available Sizes ​

SizeOrientationUse Case
1024x1024SquareGeneral purpose, icons, avatars
1536x1024LandscapeScenes, backgrounds, banners
1024x1536PortraitCharacters, posters, mobile wallpapers

If you don't specify a size, Iris defaults to 1024x1024. You can request a size naturally:

"Create a landscape banner of a beach scene" → Uses 1536x1024 "Generate a portrait-oriented poster design" → Uses 1024x1536

How It Works ​

  1. Request: Iris interprets your request and formulates a detailed prompt
  2. Generation: The prompt is sent to gpt-image-1.5 through Prism, which returns the image as base64 PNG data. The request times out after 90 seconds
  3. Display: The image streams to the chat as an artifact and appears inline
  4. Storage: When the reply is saved, the image is written to disk as an attachment on that assistant message

Storage Details ​

Generated images are stored as attachments with:

  • Path: attachments/{user id}/generated/{uuid}.png on Laravel's default filesystem disk
  • Type: Marked as generated (vs upload for user-uploaded images)
  • Description: The prompt used to generate the image
  • Conversation link: Associated with the assistant message that contains it

Deleting its thread, clearing the conversation, or deleting your account deletes the image file too.

Prompt Enhancement ​

Iris often enhances your prompts for better results:

You: "Draw a cat"

Becomes: "A photorealistic image of a domestic cat with soft fur, sitting in natural lighting, detailed eyes, high quality"

You can override this by being very specific or asking for exactly what you described:

"Generate exactly this: a simple sketch of a cat, no details, just basic outlines"

Limitations and Constraints ​

Content Policy ​

OpenAI's content policy applies. Requests that violate the policy will be rejected:

  • No realistic images of public figures
  • No violent, adult, or harmful content
  • No content that could be used for deception

If a request is rejected, Iris will explain why and suggest alternatives.

Quality Considerations ​

  • Text in images: GPT Image can include text, but it may be imperfect. For text-heavy designs, consider post-processing.
  • Specific details: Very specific requests (exact layouts, precise proportions) may not render exactly as described.
  • Consistency: Multiple requests for "the same" thing will produce variations. There's no way to get identical outputs.

Rate Limits and Costs ​

Every image is a billed OpenAI API request, and cost depends on size and quality. See OpenAI's API pricing page for current rates, and your OpenAI dashboard for your rate limits and usage. If you hit a rate limit, the tool returns the error and Iris tells you.

Troubleshooting ​

Errors in general: When generation fails, the tool returns Error generating image: followed by the provider's message, Iris relays it, and the full exception is logged as Image generation failed.

Missing or invalid API key: Add OPENAI_API_KEY to your .env file.

Request rejected by the safety system: The prompt was rejected by OpenAI's safety filters. Rephrase your request.

Image not appearing: Check that the storage disk is configured correctly and writable. Images are stored using Laravel's default disk.

Slow generation: Generation runs inside the chat turn, so the reply waits for the image. Iris gives up on the request after 90 seconds and reports the timeout.

Disabling Image Generation ​

If you don't need image generation, disable the tool:

php
// config/iris-custom.php
return [
    'disabled_tools' => [
        App\Tools\GenerateImageTool::class,
    ],
];