1import requests
2from kern.agent import Agent, RunOutput # noqa
3from kern.media import Audio
4from kern.models.openai import OpenAIResponses
5
6# Fetch the audio file and convert it to a base64 encoded string
7url = "https://openaiassets.blob.core.windows.net/$web/API/docs/audio/alloy.wav"
8response = requests.get(url)
9response.raise_for_status()
10wav_data = response.content
11
12# Provide the agent with the audio file and get result as text
13agent = Agent(
14 model=OpenAIResponses(id="gpt-5.2-audio-preview", modalities=["text"]),
15 markdown=True,
16)
17agent.print_response(
18 "What is in this audio?", audio=[Audio(content=wav_data, format="wav")]
19)