Menu

Image Generation with AI SDK

Last updated November 25, 2025

AI Gateway supports image generation through the AI SDK using two approaches: multimodal LLMs that can generate images alongside text, and image-only 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 images from Nano Banana models.

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 images from Nano Banana models.

Nano Banana models (like and ) return images as content parts in . These include a property that you can write directly to disk:

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 ).

To save generated images to disk, see Save images from OpenAI tool results.

Learn more about the OpenAI Image Generation Tool in the AI SDK documentation.

OpenAI models return images as base64-encoded strings in tool results. The approach differs depending on whether you use or .

With , images are available in after the call completes:

With , images arrive as events in the stream. Save them as they come in:

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 image-only 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 image-only models.

All generated images from image-only models are returned in as objects containing:

  • : The image as a base64-encoded string
  • : The MIME type (e.g., , , )

Was this helpful?

supported.