{"record":{"id":"fb266cb5e19e1558","repo":"vercel/ai","slug":"elevenlabs-only-supports-audio-pcmu-at-8000-hz","errorCode":null,"errorMessage":"ElevenLabs only supports audio/pcmu at 8000 Hz","messagePattern":"ElevenLabs only supports audio/pcmu at 8000 Hz","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/elevenlabs/src/elevenlabs-transcription-model.ts","lineNumber":337,"sourceCode":"        previousText: streamingOptions?.previousText ?? undefined,\n        sampleRate: inputFormat.sampleRate,\n        url,\n        warnings,\n        webSocket: this.config.webSocket,\n      }),\n    };\n  }\n}\n\nfunction getElevenLabsRealtimeAudioFormat(\n  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 };","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/elevenlabs/src/elevenlabs-transcription-model.ts#L319-L355","documentation":"InvalidArgumentError thrown by getElevenLabsRealtimeAudioFormat when an audio/pcmu input format declares a sample rate other than 8000 Hz (or omits it, which is accepted). ElevenLabs realtime transcription only accepts PCMU (u-law) at exactly 8000 Hz, mapping to 'ulaw_8000'.","triggerScenarios":"Providing inputAudioFormat { type: 'audio/pcmu', rate: 16000 } (or any rate != 8000) when constructing the realtime input format via inputFormat.","commonSituations":"Telephony integrations that resample or misconfigure PCMU streams, or developers assuming PCMU can run at higher rates like PCM can.","solutions":["Set the sample rate to 8000 for audio/pcmu input.","Omit the rate field entirely; PCMU defaults to 8000 Hz.","If your source audio is at a different rate, transcode it to 8 kHz u-law before streaming."],"exampleFix":"// before\n{ type: 'audio/pcmu', rate: 16000 }\n// after\n{ type: 'audio/pcmu', rate: 8000 }","handlingStrategy":"validation","validationCode":"function assertPcmuFormat(f: { type: string; rate?: number }) {\n  if (f.type.toLowerCase() === 'audio/pcmu' && f.rate != null && f.rate !== 8000) {\n    throw new Error('audio/pcmu must be 8000 Hz for ElevenLabs realtime');\n  }\n}","typeGuard":"function isPcmu8k(f: { type: string; rate?: number }): boolean {\n  return f.type.toLowerCase() === 'audio/pcmu' && (f.rate ?? 8000) === 8000;\n}","tryCatchPattern":null,"preventionTips":["Always send PCMU at 8 kHz (standard telephony rate).","Transcode at the media pipeline boundary, not at the API call site.","Add unit tests for audio format handling in telephony integrations."],"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"}