Skip to content

Commit ce8b98a

Browse files
authored
Fix OpenAI AudioUrl (#1594)
1 parent 56b07ae commit ce8b98a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pydantic_ai_slim/pydantic_ai/models/openai.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ async def _map_user_prompt(part: UserPromptPart) -> chat.ChatCompletionUserMessa
444444
response = await client.get(item.url)
445445
response.raise_for_status()
446446
base64_encoded = base64.b64encode(response.content).decode('utf-8')
447-
audio = InputAudio(data=base64_encoded, format=response.headers.get('content-type'))
447+
audio_format: Any = response.headers['content-type'].removeprefix('audio/')
448+
audio = InputAudio(data=base64_encoded, format=audio_format)
448449
content.append(ChatCompletionContentPartInputAudioParam(input_audio=audio, type='input_audio'))
449450
elif isinstance(item, DocumentUrl):
450451
client = cached_async_http_client()

0 commit comments

Comments
 (0)