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

# 图片生成模型

本示例展示了如何使用图片生成模型通过 WhatsApp 应用生成图片。

## 代码

```python cookbook/apps/whatsapp/image_generation_model.py theme={null}
from agno.agent import Agent
from agno.app.whatsapp.app import WhatsappAPI
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,
)

whatsapp_app = WhatsappAPI(
    agent=image_agent,
    name="图片生成模型",
    app_id="image_generation_model",
    description="一个使用 Gemini API 生成图片的模型。",
)

app = whatsapp_app.get_app()

if __name__ == "__main__":
    whatsapp_app.serve(app="image_generation_model:app", port=8000, reload=True)

```

## 用法

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

  <Step title="设置您的 API 密钥">
    ```bash theme={null}
    export GOOGLE_API_KEY=xxx
    ```
  </Step>

  <Step title="安装库">
    ```bash theme={null}
    pip install -U agno google-generativeai "uvicorn[standard]"
    ```
  </Step>

  <Step title="运行 Agent">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/apps/whatsapp/image_generation_model.py
      ```

      ```bash Windows theme={null}
      python cookbook/apps/whatsapp/image_generation_model.py
      ```
    </CodeGroup>
  </Step>
</Steps>
