{"record":{"id":"434ad6e3f387ba7e","repo":"agentscope-ai/agentscope","slug":"unsupported-audio-media-type-media-type-only-w","errorCode":null,"errorMessage":"Unsupported audio media type: {media_type}, only WAV and MP3 audio are supported.","messagePattern":"Unsupported audio media type: (.+?), only WAV and MP3 audio are supported\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/formatter/_openai_formatter.py","lineNumber":146,"sourceCode":"        Local ``file://`` URLs are read from disk. Remote URLs are downloaded.\n        Only ``wav`` and ``mp3`` formats are supported by the OpenAI API.\n\n        Args:\n            source (`URLSource | Base64Source`):\n                The audio source to convert.\n\n        Returns:\n            `dict[str, Any]`:\n                A dictionary with ``\"type\": \"input_audio\"`` in OpenAI format.\n        \"\"\"\n        media_type_to_format = {\n            \"audio/wav\": \"wav\",\n            \"audio/mp3\": \"mp3\",\n            \"audio/mpeg\": \"mp3\",\n        }\n        media_type = source.media_type\n        if media_type not in media_type_to_format:\n            raise TypeError(\n                f\"Unsupported audio media type: {media_type}, \"\n                \"only WAV and MP3 audio are supported.\",\n            )\n        audio_format = media_type_to_format[media_type]\n\n        if isinstance(source, Base64Source):\n            return {\n                \"type\": \"input_audio\",\n                \"input_audio\": {\n                    \"data\": source.data,\n                    \"format\": audio_format,\n                },\n            }\n\n        if isinstance(source, URLSource):\n            url_str = str(source.url)\n            if url_str.startswith(\"file://\"):\n                # Local file","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/formatter/_openai_formatter.py#L128-L164","documentation":"OpenAI audio input only supports WAV and MP3, so _format_audio_source maps media types (audio/wav, audio/mp3, audio/mpeg) to a format string and raises TypeError for anything else (e.g. audio/ogg, audio/webm, audio/flac). This is a provider limitation, not a generic validation error.","triggerScenarios":"Passing an AudioBlock whose source.media_type is e.g. 'audio/ogg', 'audio/webm' (common for browser MediaRecorder output), 'audio/m4a', or a missing/None media_type to the OpenAI formatter.","commonSituations":"Feeding browser-recorded webm/ogg audio straight to the API; converting voice notes to flac/m4a and assuming support; omitting media_type so it defaults to something unsupported.","solutions":["Transcode the audio to WAV or MP3 (e.g. with ffmpeg: ffmpeg -i in.webm out.mp3) and set media_type to 'audio/mpeg' or 'audio/wav'","Ensure media_type is set correctly on Base64Source/URLSource — 'audio/mpeg' (not 'audio/mp3') is the standard MIME for MP3","If you must keep other formats, use the OpenAI Responses/Transcription APIs or another provider that accepts them"],"exampleFix":"# before\nAudioBlock(source=Base64Source(data=b64, media_type=\"audio/webm\"), alt=\"voice\")\n\n# after (transcode first: ffmpeg -i in.webm out.mp3)\nAudioBlock(source=Base64Source(data=b64_mp3, media_type=\"audio/mpeg\"), alt=\"voice\")","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"audio/wav\", \"audio/mp3\", \"audio/mpeg\"}\nassert source.media_type in SUPPORTED, f\"{source.media_type} not supported by OpenAI audio input\"","typeGuard":"def is_openai_audio_media_type(media_type: str | None) -> bool:\n    return media_type in {\"audio/wav\", \"audio/mp3\", \"audio/mpeg\"}","tryCatchPattern":"try:\n    formatter.format(msgs)\nexcept TypeError as e:\n    if \"Unsupported audio media type\" in str(e):\n        audio = transcode_to_mp3(audio)  # e.g. ffmpeg\n        ...  # rebuild block with media_type='audio/mpeg' and retry\n    else:\n        raise","preventionTips":["Transcode browser recordings (webm/ogg) to WAV or MP3 before sending","Use 'audio/mpeg' as the MIME type for MP3 files","Always set media_type explicitly on audio sources"],"tags":["openai","audio","media-type","multimodal","agentscope"],"backgroundTag":"unsupported-media-format","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}