vercel/ai · error · InvalidArgumentError
providerOptions.elevenlabs.streaming.filterBackgroundAudio c
Error message
providerOptions.elevenlabs.streaming.filterBackgroundAudio cannot be combined with includeTimestamps or includeLanguageDetection
What it means
InvalidArgumentError thrown by doStream when providerOptions.elevenlabs.streaming.filterBackgroundAudio is true while includeTimestamps or includeLanguageDetection is also true. The ElevenLabs realtime speech-to-text API does not allow combining background-audio filtering with timestamps or language detection in one stream.
Source
Thrown at packages/elevenlabs/src/elevenlabs-transcription-model.ts:281
) {
warnings.push({
type: 'unsupported',
feature: `providerOptions.elevenlabs.${option}`,
details: `ElevenLabs realtime transcription does not support ${option}.`,
});
}
}
// ElevenLabs documents filter_background_audio as incompatible with
// include_timestamps. Language detection is delivered on the same
// timestamp-bearing event, so it also requires include_timestamps here.
// https://elevenlabs.io/docs/api-reference/speech-to-text/v-1-speech-to-text-realtime
if (
streamingOptions?.filterBackgroundAudio === true &&
(streamingOptions.includeTimestamps === true ||
streamingOptions.includeLanguageDetection === true)
) {
throw new InvalidArgumentError({
argument: 'providerOptions',
message:
'providerOptions.elevenlabs.streaming.filterBackgroundAudio cannot be combined with includeTimestamps or includeLanguageDetection',
});
}
const inputFormat = getElevenLabsRealtimeAudioFormat(
options.inputAudioFormat,
);
const url = buildElevenLabsRealtimeTranscriptionUrl({
baseUrl: toWebSocketUrl(
this.config.url({
path: '/v1/speech-to-text/realtime',
modelId: this.modelId,
}),
),
inputFormat: inputFormat.audioFormat,
languageCode: elevenLabsOptions?.languageCode ?? undefined,View on GitHub (pinned to 69428b1f8b)
Solutions
- Remove filterBackgroundAudio: true if you need timestamps or language detection.
- Or remove includeTimestamps/includeLanguageDetection if background-audio filtering is required.
- Run two passes (one filtered, one with timestamps) if you need both capabilities.
Example fix
// before
providerOptions: { elevenlabs: { streaming: { filterBackgroundAudio: true, includeTimestamps: true } } }
// after
providerOptions: { elevenlabs: { streaming: { includeTimestamps: true } } } Defensive patterns
Strategy: validation
Validate before calling
const s = providerOptions?.elevenlabs?.streaming;
if (s?.filterBackgroundAudio === true && (s.includeTimestamps === true || s.includeLanguageDetection === true)) {
throw new Error('filterBackgroundAudio cannot be combined with includeTimestamps or includeLanguageDetection');
} Try / catch
try {
await model.doStream(options);
} catch (e) {
if (InvalidArgumentError.isInstance?.(e) || (e as Error).message.includes('filterBackgroundAudio')) {
// strip the conflicting option and retry
}
throw e;
} Prevention
- Validate providerOptions against an app-level schema before each request.
- Document mutually exclusive realtime options in your options-builder UI/API.
- Read the ElevenLabs realtime speech-to-text API reference for option constraints.
When it happens
Trigger: Passing providerOptions: { elevenlabs: { streaming: { filterBackgroundAudio: true, includeTimestamps: true } } } (or includeLanguageDetection: true) to a realtime transcription doStream call.
Common situations: Developers enable all realtime options at once for better quality without knowing the API-level incompatibility documented in the ElevenLabs realtime speech-to-text docs.
Related errors
- Invalid argument for parameter output: Invalid output type.
- Invalid argument for parameter schemaName: Schema name is no
- Invalid argument for parameter enumValues: Enum values are r
- Invalid argument for parameter enumValues: Enum values must
- ElevenLabs only supports audio/pcmu at 8000 Hz
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/a2477ea526555f8b.
Report an issue: GitHub.