ai icon indicating copy to clipboard operation
ai copied to clipboard

groq-transcription-model.ts: Transcription Fails Due to Missing File Extension in formData

Open jie-lyu opened this issue 1 year ago • 7 comments

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"

jie-lyu avatar May 21 '25 07:05 jie-lyu

I'm also experiencing this.

cameronapak avatar May 21 '25 12:05 cameronapak

Getting the same error!

AlexGodard avatar May 24 '25 21:05 AlexGodard

Also here, would love to see this fixed ;)

loudar avatar Jun 17 '25 13:06 loudar

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));

jinhong- avatar Jun 30 '25 21:06 jinhong-

Still getting the same error at V5, looks like it hasnt been fixed

AndreHMachado avatar Aug 18 '25 18:08 AndreHMachado

I'm working on https://github.com/vercel/ai/pull/8159 that should resolve the problem.

gr2m avatar Aug 19 '25 20:08 gr2m

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.

lgrammel avatar Jul 22 '26 15:07 lgrammel