> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.boundaryml.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.boundaryml.com/_mcp/server.

# BamlValidationError

> Technical reference for the BamlValidationError class

The `BamlValidationError` class represents an error that occurs when BAML fails to parse or validate LLM output.

## Type Definition

```typescript Type Definition
class BamlValidationError extends Error {
  type: 'BamlValidationError'
  message: string
  prompt: string
  raw_output: string
  detailed_message: string
}
```

## Properties

Literal type identifier for the error class.

Error message describing the specific validation failure.

The original prompt sent to the LLM.

The raw output from the LLM that failed validation.

Comprehensive error information that includes the complete history of all failed attempts when using fallback clients or retry policies. When multiple attempts are made (via fallback or retry), this field contains formatted details about each failed attempt, making it invaluable for debugging complex client configurations.

## Type Guards

The error can be identified using TypeScript's `instanceof` operator:

```typescript Type Check
if (error instanceof BamlValidationError) {
  // Handle validation error
}
```

## Related Errors

* [BamlClientFinishReasonError](/ref/baml_client/errors/baml-client-finish-reason-error)
* [BamlClientError](/ref/baml_client/errors/baml-client-finish-reason-error)