groq-transcription-model.ts: Transcription Fails Due to Missing File Extension in formData
Description
File: https://github.com/vercel/ai/blob/main/packages/groq/src/groq-transcription-model.ts
Problem: The current implementation in groq-transcription-model.ts for creating the formData appends a file with a static filename "audio" without an extension:
formData.append('file', new File([blob], 'audio', { type: mediaType }));
This causes the Groq API to return an invalid_request_error because it expects a filename with one of the supported audio file extensions.
Error Message from Groq API:
{
"error": {
"message": "file must be one of the following types: [flac mp3 mp4 mpeg mpga m4a ogg opus wav webm]",
"type": "invalid_request_error"
}
}
AI SDK Version
- "ai": "^4.3.16"
- "@ai-sdk/groq": "^1.2.9"
I'm also experiencing this.
Getting the same error!
Also here, would love to see this fixed ;)
It is the same issue for azure openai provider as well. I manually patched up the js/mjs files to fix this error. The following fixes this issue for me in azure but would love to see an official patch/fix done
function mimeToExtension(mime) {
var map = {
'audio/mpeg': 'mp3',
'audio/mp3': 'mp3',
'audio/wav': 'wav',
'audio/x-wav': 'wav',
'audio/webm': 'webm',
'audio/ogg': 'ogg',
'audio/opus': 'ogg',
'audio/mp4': 'm4a',
'audio/x-m4a': 'm4a',
'audio/flac': 'flac',
'audio/aac': 'aac',
};
if(!map[mime]) throw new Error('mime type ' + mime + ' is unsupported');
return map[mime];
}
formData.append("file", new File([blob], "audio", { type: mediaType }), 'audio.' + mimeToExtension(mediaType));
Still getting the same error at V5, looks like it hasnt been fixed
I'm working on https://github.com/vercel/ai/pull/8159 that should resolve the problem.
Identify issue type
Identified as Bug
Confidence: High
Rationale
This is a concrete failure in existing transcription behavior: the provider constructs multipart form data with an invalid filename, causing supported audio requests to be rejected by Groq.
Evidence
- The Groq transcription provider sends the uploaded audio with the static filename "audio" and no extension.
- Groq rejects the request with an invalid_request_error requiring a supported audio file extension.
- Multiple users reproduced the failure, including in AI SDK v5, and a maintainer-linked pull request is intended to resolve it.