Skip to main content

Installation Steps

1

Install BAML VSCode Extension

Install the extension from: https://marketplace.visualstudio.com/items?itemName=boundary.baml-extensionFeatures include:
  • Syntax highlighting
  • Testing playground
  • Prompt previews
2

Install BAML

Install the BAML gem and Sorbet runtime:
bundle add baml sorbet-runtime
3

Initialize BAML in Your Project

This creates a baml_src directory with starter BAML code:
bundle exec baml-cli init
4

Generate Ruby Code

Generate the Ruby client from your .baml files:
bundle exec baml-cli generate
This creates a type-safe Ruby module interface to every BAML function. Any types defined in .baml files will be converted into Ruby classes.
If you have the VSCode extension installed, it will automatically run this command when you save a BAML file.
5

Use BAML Functions in Ruby

Import and use your generated BAML client:
require_relative "baml_client/client"

def example(raw_resume)
  # r is an instance of Baml::Types::Resume, 
  # defined in baml_client/types
  r = Baml.Client.ExtractResume(resume: raw_resume)

  puts "ExtractResume response:"
  puts r.inspect
end

example 'Grace Hopper created COBOL'

Build docs developers (and LLMs) love