zylon-ai/private-gpt · error · Errors.InvalidRequest
INVALID_REQUEST_AUDIO_MAX_NUM_ERROR
INVALID_REQUEST_AUDIO_MAX_NUM_ERROR
Error message
The LLM supports a maximum of {max_num_audios} audios, but the message contains {len(audios)} What it means
Raised by ValidatorRequestInterceptor before the LLM is called when the last user message contains more AudioBlocks than the model supports. The interceptor collects audio blocks from the last user message, checks audio support via supports_audio(), then compares the count against max_audios_supported(llm, model_config). It is a client-side request validation error (Errors.InvalidRequest with code INVALID_REQUEST_AUDIO_MAX_NUM_ERROR).
Source
Thrown at private_gpt/server/chat/interceptors/validator_request_interceptor.py:104
if len(images) > max_num_images:
raise Errors.InvalidRequest(
f"The LLM supports a maximum of {max_num_images} images, but the message contains {len(images)}",
Errors.Codes.INVALID_REQUEST_IMAGE_MAX_NUM_ERROR,
)
# Validate multimodal inputs (audios)
audios: list[AudioBlock] = [
audio for audio in last_user_message.blocks if isinstance(audio, AudioBlock)
]
if audios:
if not supports_audio(llm, model_config):
raise Errors.InvalidRequest(
"The LLM does not support audio, but the message contains audio blocks.",
Errors.Codes.INVALID_REQUEST_AUDIO_SUPPORT_ERROR,
)
max_num_audios = max_audios_supported(llm, model_config)
if len(audios) > max_num_audios:
raise Errors.InvalidRequest(
f"The LLM supports a maximum of {max_num_audios} audios, but the message contains {len(audios)}",
Errors.Codes.INVALID_REQUEST_AUDIO_MAX_NUM_ERROR,
)
token_limit = context.state.runtime.effective_token_limit
tokenize = context.state.runtime.tokenizer_fn
if token_limit is None or tokenize is None:
return
user_message_tokens = len(
await async_tokenizer(texts=user_text, tokenizer_fn=tokenize)
)
if user_message_tokens > token_limit:
raise Errors.RequestTooLarge(
f"The message length {user_message_tokens} exceeds the maximum token limit {token_limit}.",
Errors.Codes.REQUEST_TOO_LARGE_USER_MSG,
)
View on GitHub (pinned to 4a030776a3)
Solutions
- Reduce the number of AudioBlocks in the last user message to at most max_audios_supported() for the configured model.
- Check max_audios_supported(llm, model_config) client/server-side before building the message and split extra audios into separate requests.
- Switch to a model configuration that supports the required number of audio inputs.
- If the limit reported is 0, verify the model config actually enables audio (otherwise error 359 INVALID_REQUEST_AUDIO_SUPPORT_ERROR applies instead).
Example fix
// before msg = ChatMessage(role=MessageRole.USER, blocks=[TextBlock(text='transcribe these'), *audio_blocks]) // 5 audios, model supports 1 // after audio_blocks = audio_blocks[:max_audios_supported(llm, model_config)] msg = ChatMessage(role=MessageRole.USER, blocks=[TextBlock(text='transcribe this'), *audio_blocks])
Defensive patterns
Strategy: validation
Validate before calling
from private_gpt.ui.helpers import max_audios_supported # or the module where it lives count = sum(isinstance(b, AudioBlock) for b in last_user_message.blocks) assert count <= max_audios_supported(llm, model_config), 'too many audios'
Type guard
def within_audio_limit(msg: ChatMessage, limit: int) -> bool:
return sum(isinstance(b, AudioBlock) for b in msg.blocks) <= limit Try / catch
try:
await chat_facade.create_chat_event_generator(request=request)
except Errors.InvalidRequest as e:
if e.code == Errors.Codes.INVALID_REQUEST_AUDIO_MAX_NUM_ERROR:
audios = audios[:max_audios_supported(llm, model_config)] # trim and retry once Prevention
- Cap audio attachments in the UI at max_audios_supported for the active model
- Validate block counts before submitting the request
- Read the model's multimodal limits from model_config at startup
When it happens
Trigger: POST /v1/chat/completions (or the chat facade) with a ChatMessage whose blocks include more AudioBlock instances than the configured model's audio limit; e.g. attaching 3 audio clips to a model that supports 1.
Common situations: Switching from a multimodal model (high audio limit) to a text-only or single-audio model without trimming attachments; UI allowing unlimited audio uploads while the backend model config declares a small max; batch transcription-style requests stuffing many audios into one message.
Related errors
- REQUEST_TOO_LARGE_USER_MSG
- Audio blocks found but no audio-capable LLM provided.
- Failed to describe audio in the message.
- Multimodal input provided but tokenizer is not multimodal
- RemoteTokenizeTokenizer only supports text tokenization
AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15).
Data as JSON: /api/errors/26c47a472c82baf9.
Report an issue: GitHub.