Image Generation
Generate images using AI models through the AgnicPay AI Gateway
Image Generation
Generate images from text prompts using AI models with image output capabilities. AgnicPay supports various image generation models that can create high-quality images based on your descriptions.
Overview
Image generation is available through models that have "image" in their output_modalities. These models can create images from text prompts when you specify the appropriate modalities in your request.
Basic Image Generation
Python
JavaScript
cURL
Image Configuration Options
Some models support additional configuration through the image_config parameter.
Aspect Ratio
Set image_config.aspect_ratio to request specific aspect ratios:
| Ratio | Resolution | Use Case |
|---|---|---|
1:1 | 1024×1024 | Social media, avatars |
16:9 | 1344×768 | Widescreen, presentations |
9:16 | 768×1344 | Mobile, stories |
4:3 | 1184×864 | Standard photos |
3:2 | 1248×832 | Classic photography |
Example with Configuration
Response Format
Generated images are returned in the assistant message:
Image Format Details
- Format: Images are returned as base64-encoded data URLs
- Type: Typically PNG format (
data:image/png;base64,) - Multiple Images: Some models can generate multiple images
- Size: Dimensions vary by model and configuration
Saving Generated Images
Python
JavaScript
Compatible Models
Models with image generation capabilities:
| Model | Provider | Features |
|---|---|---|
google/gemini-2.0-flash | Fast generation, configurable |
Check the model's architecture.output_modalities for "image" support. Visit AI Gateway Pricing for the full list.
Best Practices
- Clear prompts - Provide detailed descriptions for better results
- Specify style - Include artistic style, mood, lighting preferences
- Set aspect ratio - Match the ratio to your use case
- Error handling - Check for the
imagesfield before processing
Troubleshooting
No images in response?
- Verify the model supports image generation
- Ensure
modalities: ["image", "text"]is in your request - Check that your prompt requests image generation
Wrong dimensions?
- Use the
image_config.aspect_ratioparameter - Check model-specific documentation for supported ratios