OpenAI Image Generation
Image generation service implementation using OpenAI’s DALL-E models
Overview
OpenAIImageGenService
provides high-quality image generation capabilities using OpenAI’s DALL-E models. It transforms text prompts into images with various size options and model configurations.
Installation
No additional installation is required for the OpenAIImageGenService
as it is part of the Pipecat AI package.
You’ll also need an OpenAI API key for authentication.
Configuration
Constructor Parameters
OpenAI API key for authentication
Optional base URL for OpenAI API requests
HTTP session for making requests
Image dimensions - one of “256x256”, “512x512”, “1024x1024”, “1792x1024”, “1024x1792”
OpenAI model identifier for image generation
Input
The service accepts text prompts through its image generation pipeline.
Output Frames
URLImageRawFrame
Generated image URL from OpenAI
Raw image data
Image dimensions (width, height)
Image format (e.g., ‘JPEG’)
ErrorFrame
Error information if generation fails
Usage Example
Frame Flow
Metrics Support
The service supports metrics collection:
- Time to First Byte (TTFB)
- Processing duration
- API response metrics
Model Support
OpenAI’s image generation service offers different model variants:
Model ID | Description |
---|---|
dall-e-3 | Latest DALL-E model with higher quality and better prompt following |
dall-e-2 | Previous generation model with good quality and lower cost |
Image Size Options
Size Option | Aspect Ratio | Description |
---|---|---|
256x256 | 1:1 | Small square image |
512x512 | 1:1 | Medium square image |
1024x1024 | 1:1 | Large square image |
1792x1024 | 16:9 | Horizontal/landscape orientation |
1024x1792 | 9:16 | Vertical/portrait orientation |