BoundaryML/baml · error

AWS Bedrock does not support audio media type

Error message

AWS Bedrock does not support audio media type: {:#?}

What it means

BAML's AWS Bedrock client does not implement any ContentBlock mapping for audio media, so if a prompt contains audio (BamlMediaType::Audio) sent to a Bedrock provider, the client refuses the request outright. Unlike the base64 invariant errors, this is an intentional, documented capability limitation, not an internal bug.

Solutions

  1. Remove the audio media from the prompt or transcribe it to text before sending.
  2. Switch the client to a provider that supports audio input (e.g. OpenAI, Google AI).
  3. Use a fallback/strategy client so Bedrock requests never receive audio parts.
  4. Watch BAML releases for Bedrock audio support and upgrade when available.

Example fix

// before (baml)
client "bedrock" { provider "aws-bedrock" ... }
// after — use an audio-capable provider
client "gpt4o-audio" { provider "openai" ... }
Defensive patterns

Strategy: validation

Validate before calling

if (clientProvider === 'aws-bedrock' && promptMedia.some(m => m.type === 'audio')) { throw new Error('Bedrock client does not support audio media; use a different provider or transcribe first.'); }

Type guard

const hasAudio = (parts) => parts.some(p => p?.type === 'audio' || p?.media_type === 'audio');

Try / catch

try { await b.MyPrompt(...) } catch (e) { if (String(e).includes('does not support audio media type')) { /* route to OpenAI/Google client or strip audio */ } else throw e; }

Prevention

When it happens

Trigger: Including an audio media argument (baml_audio / audio media) in a prompt executed against an AWS Bedrock client, regardless of content resolution state.

Common situations: Building a multimodal prompt with audio that works on OpenAI or Google providers, then switching the client/provider to aws-bedrock without realizing Bedrock audio input is unsupported in BAML.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/30f3e198658bc505. Report an issue: GitHub.

Appendix: source

Thrown at engine/baml-runtime/src/internal/llm_client/primitive/aws/aws_client.rs:1261

                                    .build()
                                    .context("Failed to build S3Location block")?,
                            )))
                            .build()
                            .context("Failed to build Video document block")?,
                    )),
                    BamlMediaContent::Base64(b64_media) => Ok(bedrock::types::ContentBlock::Video(
                        bedrock::types::VideoBlock::builder()
                            .set_format(Some(format))
                            .set_source(Some(bedrock::types::VideoSource::Bytes(Blob::new(
                                aws_smithy_types::base64::decode(b64_media.base64.clone())?,
                            ))))
                            .build()
                            .context("AWS Bedrock error: mime_type must be explicitly set on base64 videos")?,
                    )),
                }
            }
            BamlMediaType::Audio => {
                anyhow::bail!(
                    "AWS Bedrock does not support audio media type: {:#?}",
                    media
                )
            }
        }
    }

    fn role_to_message(&self, msg: &RenderedChatMessage) -> Result<bedrock::types::Message> {
        let content: Vec<_> = msg
            .parts
            .iter()
            .map(|part| self.part_to_message(part))
            .collect::<Result<Vec<_>>>()?
            .into_iter()
            .flatten()
            .collect();

        bedrock::types::Message::builder()

View on GitHub (pinned to bd85ce9dee)