{"record":{"id":"df120e3ee8f21482","repo":"vercel/ai","slug":"elevenlabs-realtime-transcription-supports-audio-p","errorCode":null,"errorMessage":"ElevenLabs realtime transcription supports audio/pcm at 8000, 16000, 22050, 24000, 44100, or 48000 Hz, and audio/pcmu at 8000 Hz","messagePattern":"ElevenLabs realtime transcription supports audio/pcm at 8000, 16000, 22050, 24000, 44100, or 48000 Hz, and audio/pcmu at 8000 Hz","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/elevenlabs/src/elevenlabs-transcription-model.ts","lineNumber":348,"sourceCode":"  inputAudioFormat: TranscriptionModelV4StreamOptions['inputAudioFormat'],\n): { audioFormat: string; sampleRate: number } {\n  const type = inputAudioFormat.type.toLowerCase();\n  const rate = inputAudioFormat.rate;\n\n  if (type === 'audio/pcmu') {\n    if (rate != null && rate !== 8000) {\n      throw new InvalidArgumentError({\n        argument: 'inputAudioFormat',\n        message: 'ElevenLabs only supports audio/pcmu at 8000 Hz',\n      });\n    }\n    return { audioFormat: 'ulaw_8000', sampleRate: 8000 };\n  }\n\n  const supportedPcmRates = [8000, 16000, 22050, 24000, 44100, 48000];\n  const pcmRate = rate ?? 16000;\n  if (type !== 'audio/pcm' || !supportedPcmRates.includes(pcmRate)) {\n    throw new InvalidArgumentError({\n      argument: 'inputAudioFormat',\n      message:\n        'ElevenLabs realtime transcription supports audio/pcm at 8000, 16000, 22050, 24000, 44100, or 48000 Hz, and audio/pcmu at 8000 Hz',\n    });\n  }\n\n  return { audioFormat: `pcm_${pcmRate}`, sampleRate: pcmRate };\n}\n\nfunction buildElevenLabsRealtimeTranscriptionUrl({\n  baseUrl,\n  inputFormat,\n  languageCode,\n  modelId,\n  streamingOptions,\n}: {\n  baseUrl: URL;\n  inputFormat: string;","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/elevenlabs/src/elevenlabs-transcription-model.ts#L330-L366","documentation":"InvalidArgumentError thrown by getElevenLabsRealtimeAudioFormat when the input format is neither audio/pcmu at 8000 Hz nor audio/pcm at one of the supported rates (8000, 16000, 22050, 24000, 44100, 48000; defaulting to 16000 when rate is omitted). Anything else is rejected for realtime transcription.","triggerScenarios":"Passing inputAudioFormat like { type: 'audio/wav' }, { type: 'audio/pcm', rate: 44101 }, or { type: 'audio/mp3', rate: 48000 } to the realtime transcription inputFormat.","commonSituations":"Developers feed compressed formats (mp3, ogg, wav containers) or odd sample rates (e.g. 32000 Hz) that ElevenLabs realtime WebSocket endpoint does not accept.","solutions":["Use type 'audio/pcm' with a rate from [8000, 16000, 22050, 24000, 44100, 48000].","Use type 'audio/pcmu' with rate 8000 for telephony-grade audio.","Transcode unsupported formats/rates to raw PCM at a supported rate before streaming.","Omit the rate for PCM if 16000 Hz default is acceptable."],"exampleFix":"// before\n{ type: 'audio/mp3', rate: 32000 }\n// after\n{ type: 'audio/pcm', rate: 16000 }","handlingStrategy":"validation","validationCode":"const SUPPORTED = [8000, 16000, 22050, 24000, 44100, 48000];\nfunction assertRealtimeAudioFormat(f: { type: string; rate?: number }) {\n  const t = f.type.toLowerCase();\n  const ok = t === 'audio/pcmu' || (t === 'audio/pcm' && SUPPORTED.includes(f.rate ?? 16000));\n  if (!ok) throw new Error(`Unsupported realtime audio format: ${f.type} @ ${f.rate}`);\n}","typeGuard":"function isSupportedRealtimeFormat(f: { type: string; rate?: number }): boolean {\n  const t = f.type.toLowerCase();\n  return t === 'audio/pcmu' || (t === 'audio/pcm' && [8000,16000,22050,24000,44100,48000].includes(f.rate ?? 16000));\n}","tryCatchPattern":null,"preventionTips":["Normalize media to raw PCM at a supported rate before streaming.","Whitelist formats in your ingestion pipeline.","Resample audio (e.g. with ffmpeg/sox) as an upstream step with logged output rates."],"tags":["elevenlabs","audio-format","sample-rate","invalid-argument"],"backgroundTag":"unsupported-audio-format","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}