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

# 音频输入Agent

## 代码

```python cookbook/models/openai/chat/audio_input_agent.py theme={null}
import requests
from agno.agent import Agent, RunResponse  # noqa
from agno.media import Audio
from agno.models.openai import OpenAIChat

# 获取音频文件并将其转换为base64编码字符串
url = "https://openaiassets.blob.core.windows.net/$web/API/docs/audio/alloy.wav"
response = requests.get(url)
response.raise_for_status()
wav_data = response.content

# 为Agent提供音频文件并获取文本结果
agent = Agent(
    model=OpenAIChat(id="gpt-4o-audio-preview", modalities=["text"]),
    markdown=True,
)
agent.print_response(
    "这段音频说了什么？", audio=[Audio(content=wav_data, format="wav")]
)
```

## 用法

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

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

  <Step title="安装库">
    ```bash theme={null}
    pip install -U openai requests agno
    ```
  </Step>

  <Step title="运行Agent">
    <CodeGroup>
      ```bash Mac theme={null}
      python cookbook/models/openai/chat/audio_input_agent.py
      ```

      ```bash Windows theme={null}
      python cookbook/models/openai/chat/audio_input_agent.py
      ```
    </CodeGroup>
  </Step>
</Steps>
