BoundaryML/baml · error

AWS Bedrock modular streaming is not supported. Use non-stre

Error message

AWS Bedrock modular streaming is not supported. Use non-streaming modular requests.

What it means

build_modular_http_request constructs a non-streaming Converse HTTP request for the Bedrock modular API path, and it explicitly rejects stream=true by bailing with this message. Streaming responses for this request path were simply not implemented, so the client fails fast instead of sending a request Bedrock would reject or hang on.

Source

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

        }

        if !self.properties.additional_model_request_fields.is_empty() {
            let addl = serde_json::to_value(&self.properties.additional_model_request_fields)?;
            root.insert("additionalModelRequestFields".into(), addl);
        }

        Ok(root)
    }

    pub async fn build_modular_http_request(
        &self,
        ctx: &RuntimeContext,
        chat_messages: &[RenderedChatMessage],
        stream: bool,
        request_id: HttpRequestId,
    ) -> Result<HTTPRequest> {
        if stream {
            anyhow::bail!(
                "AWS Bedrock modular streaming is not supported. Use non-streaming modular requests."
            );
        }

        let region = self.properties.region.clone().unwrap_or_else(|| {
            ctx.env_vars()
                .get("AWS_REGION")
                .cloned()
                .unwrap_or_default()
        });

        if region.is_empty() {
            anyhow::bail!(
                "AWS region is required to build modular request. Set it in the client options or via AWS_REGION."
            );
        }

        let body_string = serde_json::to_string(&serde_json::Value::Object(

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Use the non-streaming chat API (BAML function call without stream) for this aws-bedrock client.
  2. Branch in your application code: call stream_chat only for providers that support it, falling back to chat for Bedrock modular clients.
  3. Check for a newer BAML version that adds Bedrock modular streaming support, or file/upvote an issue.

Example fix

// before
let stream = baml_client.stream.MyFunction(ctx, args)
// after
let res = baml_client.MyFunction(ctx, args) // non-streaming for aws-bedrock modular
Defensive patterns

Strategy: fallback

Validate before calling

if provider == 'aws-bedrock':
    use streaming = False  # modular path rejects stream=True

Try / catch

try:
    result = stream_chat(...)
except Exception as e:
    if 'modular streaming is not supported' in str(e):
        result = chat(...)  # fallback to non-streaming
    else:
        raise

Prevention

When it happens

Trigger: Calling stream_chat (or any streaming entry point) on an aws-bedrock client that is configured to use the modular request-building path.

Common situations: Developers adding streaming to a Bedrock-based prompt after using non-streaming chat; UI code that always calls the streaming API regardless of provider support.

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/e596d600251bf662. Report an issue: GitHub.