> ## 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/agent_with_media.py theme={null}
from agno.agent import Agent
from agno.app.whatsapp.app import WhatsappAPI
from agno.models.google import Gemini

media_agent = Agent(
    name="Media Agent",
    model=Gemini(id="gemini-2.0-flash"),
    add_history_to_messages=True,
    num_history_responses=3,
    add_datetime_to_instructions=True,
    markdown=True,
)

whatsapp_app = WhatsappAPI(
    agent=media_agent,
    name="Media Agent",
    app_id="media_agent",
    description="A agent that can send media to the user.",
)

app = whatsapp_app.get_app()

if __name__ == "__main__":
    whatsapp_app.serve(app="agent_with_media: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="运行代理">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/apps/whatsapp/agent_with_media.py
      ```

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