Skip to content

Conversation

@dmontagu
Copy link
Contributor

Right now, if you retrieve a file with mime type audio/mpeg, it will hit an assertion error because it needs to be of type mp3 when building the request to openai.

@Kludex Please take a look and fix this "properly" before the next release.

@dmontagu dmontagu enabled auto-merge (squash) July 23, 2025 04:53
@github-actions
Copy link

Docs Preview

commit: df18c93
Preview URL: https://5a6500d7-pydantic-ai-previews.pydantic.workers.dev

@dmontagu dmontagu merged commit 0f46928 into main Jul 23, 2025
14 checks passed
@dmontagu dmontagu deleted the dmontagu/fix-mp3 branch July 23, 2025 05:23
@Kludex
Copy link
Member

Kludex commented Jul 23, 2025

Please always share MREs.

This works without this PR:

from pathlib import Path

from pydantic_ai import Agent, BinaryContent

audio_file = Path('tests/assets/marcelo.mp3')
content = BinaryContent(data=audio_file.read_bytes(), media_type='audio/mpeg')

agent = Agent(model='gpt-4o-audio-preview')
result = agent.run_sync(
    ['transcribe this and identify each speaker by letter, add timestamps to each statement', content]
)
print(result.output)
print(result.usage())

KRRT7 pushed a commit to aseembits93/pydantic-ai that referenced this pull request Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants