BoundaryML/baml · error

Prompt exposure for AWS client is not supported

Error message

Prompt exposure for AWS client is not supported

What it means

chat_to_message exposes the rendered prompt as a provider-format message body; the AWS Bedrock client deliberately does not support this prompt-exposure feature and bails. Bedrock's InvokeModel/Converse flow does not provide the raw rendered prompt payload this API returns.

Solutions

  1. Use a non-AWS provider client (openai/anthropic/google/vertex) when you need raw prompt exposure
  2. Skip prompt-exposure calls for Bedrock clients and handle the error gracefully (catch the bail and return a not-supported indicator)
  3. Retrieve prompts via Bedrock-specific means or vendor tooling outside baml-runtime

Example fix

// before
let msg = provider.chat_to_message(&chat)?; // panics/bails for Bedrock
// after
let msg = match provider.chat_to_message(&chat) {
    Ok(m) => m,
    Err(e) if e.to_string().contains("Prompt exposure for AWS") => return Err(Unsupported),
    Err(e) => return Err(e.into()),
};
Defensive patterns

Strategy: try-catch

Validate before calling

// Skip exposure for Bedrock clients
if matches!(provider, LLMPrimitiveProvider::Aws(_)) {
    return Ok(None); // prompt exposure unsupported
}

Type guard

fn supports_prompt_exposure(p: &LLMPrimitiveProvider) -> bool {
    !matches!(p, LLMPrimitiveProvider::Aws(_))
}

Try / catch

match provider.chat_to_message(&chat) {
    Ok(m) => m,
    Err(e) if e.to_string().contains("Prompt exposure for AWS client") => Default::default(),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling LLMPrimitiveProvider::chat_to_message (prompt exposure / raw prompt retrieval, e.g. for prompt testing or echo features) on a client whose provider is aws-bedrock with the bedrock feature compiled in.

Common situations: Using prompt-exposure tooling (e.g. BAML's prompt preview/test APIs) against a function configured with an aws-bedrock client.

Related errors


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

Appendix: source

Thrown at engine/baml-runtime/src/internal/llm_client/primitive/mod.rs:250

        }
    }
}

impl LLMPrimitiveProvider {
    pub fn chat_to_message(
        &self,
        chat: &[RenderedChatMessage],
    ) -> Result<serde_json::Map<String, serde_json::Value>> {
        use super::traits::ToProviderMessageExt;

        match self {
            LLMPrimitiveProvider::OpenAI(client) => client.chat_to_message(chat),
            LLMPrimitiveProvider::Anthropic(client) => client.chat_to_message(chat),
            LLMPrimitiveProvider::Google(client) => client.chat_to_message(chat),
            LLMPrimitiveProvider::Vertex(client) => client.chat_to_message(chat),
            #[cfg(feature = "bedrock")]
            LLMPrimitiveProvider::Aws(client) => {
                anyhow::bail!("Prompt exposure for AWS client is not supported")
            }
        }
    }

    pub fn completion_to_provider_body(
        &self,
        prompt: &str,
    ) -> Result<serde_json::Map<String, serde_json::Value>> {
        Ok(match self {
            LLMPrimitiveProvider::OpenAI(client) => client.completion_to_provider_body(prompt),
            LLMPrimitiveProvider::Anthropic(client) => client.completion_to_provider_body(prompt),
            LLMPrimitiveProvider::Google(client) => client.completion_to_provider_body(prompt),
            LLMPrimitiveProvider::Vertex(client) => client.completion_to_provider_body(prompt),
            #[cfg(feature = "bedrock")]
            LLMPrimitiveProvider::Aws(client) => {
                anyhow::bail!("Prompt exposure for AWS client is not supported")
            }
        })

View on GitHub (pinned to bd85ce9dee)