This example shows how to use the image generation model to generate images with whatsapp app.

Code

cookbook/apps/whatsapp/image_generation_model.py
from agno.agent import Agent
from agno.app.whatsapp.app import WhatsappAPI
from agno.app.whatsapp.serve import serve_whatsapp_app
from agno.models.google import Gemini

image_agentg = Agent(
    model=Gemini(
        id="gemini-2.0-flash-exp-image-generation",
        response_modalities=["Text", "Image"],
    ),
    debug_mode=True,
)

app = WhatsappAPI(
    agent=image_agentg,
).get_app()

if __name__ == "__main__":
    serve_whatsapp_app("image_generation_model:app", port=8000, reload=True)

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.

python3 -m venv .venv
source .venv/bin/activate
2

Set your API key

export GOOGLE_API_KEY=xxx
3

Install libraries

pip install -U agno google-generativeai "uvicorn[standard]"
4

Run Agent

python cookbook/apps/whatsapp/image_generation_model.py