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

# 媒体代理

## 代码

```python cookbook/apps/discord/agent_with_media.py theme={null}
from agno.agent import Agent
from agno.app.discord import DiscordClient
from agno.models.google import Gemini

media_agent = Agent(
    name="媒体代理",
    model=Gemini(id="gemini-2.0-flash"),
    description="一个媒体处理代理",
    instructions="分析用户发送的图片、音频和视频",
    add_history_to_messages=True,
    num_history_responses=3,
    add_datetime_to_instructions=True,
    markdown=True,
)

discord_agent = DiscordClient(media_agent)
if __name__ == "__main__":
     discord_agent.serve()
```

## 用法

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

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

  <Step title="安装库">
    ```bash theme={null}
    pip install -U agno google-generativeai discord.py
    ```
  </Step>

  <Step title="运行代理">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/apps/discord/agent_with_media.py
      ```

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