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

  1. Remove filterBackgroundAudio: true if you need timestamps or language detection.
  2. Or remove includeTimestamps/includeLanguageDetection if background-audio filtering is required.
  3. 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

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


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/a2477ea526555f8b. Report an issue: GitHub.