Image Generation
Generate images from text prompts using AI providers. aiImage() supports OpenAI, Gemini, Grok, and OpenRouter with consistent parameters and fluent response handling.
BoxLang AI provides first-class image generation through the aiImage() BIF. Generate images from text descriptions using any provider that implements IAiImageService — OpenAI, Gemini, Grok, and OpenRouter — all through a unified interface.
🏗️ Architecture
📊 Provider Support Matrix
OpenAI
gpt-image-1 (default), DALL-E 3
✅
✅
✅
✅ (png/jpeg/webp)
OPENAI_API_KEY
Gemini
imagen-3.0-generate-008
✅ (aspect ratio)
❌
❌
❌
GEMINI_API_KEY
Grok / xAI
grok-2-image
✅
❌
❌
❌
GROK_API_KEY
OpenRouter
FLUX Schnell (default), many
✅
❌
❌
❌
OPENROUTER_API_KEY
⚡ Quick Start
Basic Image Generation
Multiple Images with Custom Parameters
Fluent Builder API
Embed in HTML with Data URI
Using the Built-in Agent Tool
⚙️ Module Configuration
Configure global image defaults in boxlang.json:
📋 In This Section
Parameters, options, provider-specific settings
AiImageResponse methods, saving, encoding
generateImage@bxai built-in tool
Last updated