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

# WhatsApp Image Generation Agent (Tool-based)

> WhatsApp agent that generates images using OpenAI's image generation tools

## Code

```python image_generation_tools.py theme={null}
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.openai import OpenAIChat
from agno.os.app import AgentOS
from agno.os.interfaces.whatsapp import Whatsapp
from agno.tools.openai import OpenAITools

agent_db = SqliteDb(db_file="tmp/persistent_memory.db")
image_agent = Agent(
    id="image_generation_tools",
    db=agent_db,
    model=OpenAIChat(id="gpt-4o"),
    tools=[OpenAITools(image_model="gpt-image-2")],
    markdown=True,
    add_history_to_context=True,
)

agent_os = AgentOS(
    agents=[image_agent],
    interfaces=[Whatsapp(agent=image_agent)],
)
app = agent_os.get_app()

if __name__ == "__main__":
    agent_os.serve(app="image_generation_tools:app", reload=True)
```

## Usage

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

**1. Set Environment Variables**

```bash theme={null}
export WHATSAPP_ACCESS_TOKEN=your_access_token
export WHATSAPP_PHONE_NUMBER_ID=your_phone_number_id
export WHATSAPP_VERIFY_TOKEN=your_verify_token
export WHATSAPP_APP_SECRET=your_app_secret
export OPENAI_API_KEY=your_openai_api_key
```

See the [WhatsApp setup guide](https://agno-v2.mintlify.site/agent-os/interfaces/whatsapp/setup.md) for how to get these values from the [Meta Developer Dashboard](https://developers.facebook.com/apps/).

**2. Install dependencies**

```bash theme={null}
uv pip install -U "agno[os]" openai
```

**3. Run Example**

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

## Key Features

* **Tool-based Generation**: OpenAI's GPT Image 2 model via external tools
* **Conversational Interface**: Natural language interaction for image requests
* **History Context**: Remembers previous images and conversations
* **GPT-4o Orchestration**: Manages the conversation and decides when to call the image tool


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