Image Generation with AI SDK
AI Gateway supports image generation through the AI SDK using two approaches: multimodal LLMs that can generate images alongside text, and dedicated image generation models.
You can view all available models that support image generation by using the Image filter at the AI Gateway Models page.
These models can generate both text and images in their responses. They use or functions with special configuration to enable image outputs.
Google's Nano Banana model offers fast, efficient image generation alongside text responses. Images are returned as content parts in .
To save generated images to disk, see Save generated images.
Google's Nano Banana Pro model offers state-of-the-art image generation and editing capabilities with higher quality outputs. Images are returned as content parts in .
To save generated images to disk, see Save generated images.
OpenAI's GPT-5 model variants and a few others support multi-modal image generation through a provider-defined tool. The image generation uses behind the scenes. Images are returned as tool results in (for ) or as events (for ).
Learn more about the OpenAI Image Generation Tool in the AI SDK documentation.
OpenAI images are returned as base64-encoded strings. To save them to disk, you'll need to decode the base64 string first. For multimodal models that return images in , see Save generated images.
After generating images with multimodal LLMs, you can save them to your local filesystem. Images are available in and include a property that you can write directly to disk.
These models are specialized for image generation and use the function.
Google's Imagen models provide high-quality image generation with fine-grained control over output parameters. Multiple Imagen models are available, including but not limited to:
To save generated images to disk, see Save generated images from dedicated models.
Black Forest Labs' Flux models offer advanced image generation with support for various aspect ratios and capabilities. Multiple Flux models are available, including but not limited to:
To save generated images to disk, see Save generated images from dedicated models.
All generated images from dedicated image models are returned as objects containing:
- : The image as a base64-encoded string
- : The MIME type (e.g., , , )
You can save images to disk, display them in your application, or process them further as needed.
Was this helpful?