# `Puck.Backends.Baml`
[🔗](https://github.com/bradleygolden/puck/blob/v0.2.25/lib/puck/backends/baml.ex#L2)

Backend implementation using BAML for structured outputs.

BAML provides type-safe structured outputs and is well-suited for building
agentic loops. See the [BAML documentation](https://docs.boundaryml.com/)
for details on defining functions and building agentic patterns.

## Configuration

- `:function` - (required) The BAML function name to call
- `:args` - Custom arguments map or function
- `:args_format` - How to build args: `:auto`, `:messages`, `:messages_multimodal`, `:text`, or `:raw`
- `:client_registry` - Runtime client registry for LLM provider configuration
- `:path` - Path to BAML source files (defaults to `baml_src`)

## Examples

    # Basic usage
    client = Puck.Client.new({Puck.Backends.Baml, function: "ExtractPerson"})
    {:ok, result, _ctx} = Puck.call(client, "John is 30 years old")

    # With custom args
    client = Puck.Client.new({Puck.Backends.Baml,
      function: "ClassifyIntent",
      args: %{categories: ["question", "statement", "command"]}
    })

## Telemetry

When a call or stream returns an error, this backend emits a
`[:puck, :backend, :baml, :error]` event. See `Puck.Telemetry` for details.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
