> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Model Output

> Return generated images from model responses.

Similar to providing image inputs, you can also get image outputs from an agent.

## Image Output Modality

The following example demonstrates how some models can directly generate images as part of their response.

```python image_agent.py theme={null}
from io import BytesIO

from agno.agent import Agent, RunOutput  # noqa
from agno.models.google import Gemini
from PIL import Image

agent = Agent(
    model=Gemini(
        id="gemini-3.1-flash-image",
        response_modalities=["Text", "Image"], # Generate both images and text in the response
    )
)

# Print the response in the terminal
run_response = agent.run("Make me an image of a cat in a tree.")

if run_response and isinstance(run_response, RunOutput) and run_response.images:
    for image_response in run_response.images:
        image_bytes = image_response.content
        if image_bytes:
            image = Image.open(BytesIO(image_bytes))
            image.show()
            # Save the image to a file
            # image.save("generated_image.png")
else:
    print("No images found in run response")
```

> [!TIP]
>
> You can find all generated images in the `RunOutput.images` list.

## Usage

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U google-genai pillow agno
```

**2. Export your Google API key**

```bash Mac/Linux theme={null}
  export GOOGLE_API_KEY="your_google_api_key_here"
```

```bash Windows theme={null}
  $Env:GOOGLE_API_KEY="your_google_api_key_here"
```

**3. Run Agent**

```bash theme={null}
python image_agent.py
```

## Developer Resources

* [More examples](https://agno-v2.mintlify.site/models/providers/native/google/usage/image-generation-stream.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.