baml
baml copied to clipboard
[feat] Add support for Gleam
Product
BAML
Problem Statement / Use Case
Gleam developers currently cannot use BAML for type-safe LLM interactions. Gleam is a growing language in the BEAM ecosystem that compiles to both Erlang and JavaScript, making it suitable for building reliable, concurrent systems. Adding Gleam support would enable:
- Type-safe LLM integration in Gleam web services and applications
- BEAM ecosystem adoption of BAML alongside existing Elixir support
- Elixir/Erlang projects migrating to Gleam to continue using BAML
Proposed Solution
Add official Gleam language client support to BAML by implementing:
-
Code Generator: Generate Gleam types and functions from BAML schemas
- Location:
engine/language_client_gleam/ - Pattern: Follow existing TypeScript/Go/Ruby client implementations
- Location:
-
Runtime Library: Gleam package for runtime communication
- HTTP client for BAML server interaction
- Type-safe request/response handling
- Streaming support via OTP actors
-
CLI Integration: Add
--target gleamtobaml generatecommand
Implementation would follow the established pattern used for Go and Ruby clients, generating idiomatic Gleam code with proper type safety and error handling using Result types.
Alternative Solutions
-
Community Package: Third-party Gleam wrapper around TypeScript/Python client
- Pros: No maintenance burden on BAML team
- Cons: Indirect integration, potential version mismatches, unofficial support
-
JavaScript FFI: Use BAML TypeScript client via Gleam's JS compilation target
- Pros: Reuses existing client
- Cons: Only works on JS target, loses BEAM platform benefits
Additional Context
- Gleam has official HTTP and JSON libraries suitable for client implementation
- The language emphasizes type safety and reliability, aligning with BAML's goals
- Implementation complexity is similar to the Ruby client (HTTP-based communication)
related: https://github.com/emilsoman/baml_elixir
Yes please! Gleam + Baml is the future