generateImage() function with support for various AI image models.
Basic Usage
Generate an image from a text prompt:Configuration Options
Customize image generation:Available sizes depend on the provider and model. Common sizes include:
256x256512x5121024x10241792x1024(landscape)1024x1792(portrait)
Image Response Format
ThegenerateImage() function returns:
Multiple Images
Generate multiple variations:Handling Image Data
- Save to File
- Display in Browser
- Upload to Storage
Revised Prompts
Some providers modify your prompt for better results:Image Sizes
Different models support different sizes:- Square
- Landscape
- Portrait
Prompt Engineering Tips
Write effective prompts for better results:Be specific and descriptive
Be specific and descriptive
Include style and quality keywords
Include style and quality keywords
Specify composition and perspective
Specify composition and perspective
Add technical details for realism
Add technical details for realism
Error Handling
Handle image generation errors:Provider-Specific Options
Use provider-specific features:Provider options are namespaced by provider name and validated by each provider adapter. Check the provider docs for available options.
Practical Examples
- Logo Generator
- Product Mockup
- Illustration Generator
Best Practices
Handle both URL and base64 responses
Handle both URL and base64 responses
Different providers return different formats:
Store generated images permanently
Store generated images permanently
URLs may expire - save images you need:
Use appropriate sizes for your use case
Use appropriate sizes for your use case
Smaller sizes are faster and cheaper:
Next Steps
Multi-Modal
Use images in chat conversations
Chat Completion
Generate text responses
Tool Calling
Combine image generation with tools
Embeddings
Generate vector embeddings