BoundaryML/baml · error

{message}

Error message

{message}

What it means

When a provider returns LLMResponse::LLMFailure with ErrorCode::Other(2), BAML treats the message as an internal BAML error and surfaces the raw message string as a plain anyhow error instead of a typed ExposedError. This path exists so internal BAML-level failures (not HTTP failures) propagate their own message unchanged.

Solutions

  1. Read the surfaced message - it is the internal error text - and fix the referenced configuration or input.
  2. Validate clients.baml: provider names, required options (api_key, model), and retry strategy references.
  3. Confirm the api_key env var is set and spelled exactly as referenced in options.
  4. Update the BAML CLI/runtime version; internal error codes can shift between versions.
  5. If it persists, search/track the message against BAML issues on GitHub.

Example fix

// before (clients.baml) - typo'd env var, client fails to build
client<Chat> {
  provider openai
  options { model gpt-4o api_key env.OPENAI_API_KEY_TYPO }
}
// after
client<Chat> {
  provider openai
  options { model gpt-4o api_key env.OPENAI_API_KEY }
}
Defensive patterns

Strategy: validation

Validate before calling

# before calling, validate clients.baml essentials
import os
assert os.environ.get("OPENAI_API_KEY"), "OPENAI_API_KEY not set"
# and ensure client/provider names referenced in functions exist in clients.baml

Try / catch

// python
try:
    result = b.ExtractDocs(text)
except Exception as e:
    # internal BAML errors arrive as plain messages; log full text for diagnosis
    log.error("BAML internal error: %s", e)
    raise

Prevention

When it happens

Trigger: Any BAML function call whose orchestrator node receives LLMResponse::LLMFailure with code ErrorCode::Other(2) - internal BAML errors such as client misconfiguration or provider-client construction failures raised during single_call.

Common situations: Misconfigured clients.baml (bad provider name, unsupported option), errors building the provider client at request time, or BAML-internal validation failures that are neither timeouts nor HTTP status errors.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at engine/baml-runtime/src/internal/llm_client/orchestrator/call.rs:146

                        code,
                        client,
                        message,
                        raw_response,
                        ..
                    }) => {
                        match code {
                            // Timeout error
                            crate::internal::llm_client::ErrorCode::Timeout => {
                                Some(Err(anyhow::anyhow!(
                                    crate::errors::ExposedError::TimeoutError {
                                        client_name: client.clone(),
                                        message: message.clone(),
                                    }
                                )))
                            }
                            // This is some internal BAML error, so handle it like any other error
                            crate::internal::llm_client::ErrorCode::Other(2) => {
                                Some(Err(anyhow::anyhow!(message.clone())))
                            }
                            _ => Some(Err(anyhow::anyhow!(
                                crate::errors::ExposedError::ClientHttpError {
                                    client_name: client.clone(),
                                    message: message.clone(),
                                    status_code: code.clone(),
                                    detailed_message: message.clone(),
                                    raw_response: raw_response.clone(),
                                }
                            ))),
                        }
                    }
                    _ => None,
                };

                let sleep_duration = node.error_sleep_duration().cloned();
                let result = (node.scope, response, parsed_response);

View on GitHub (pinned to bd85ce9dee)