Skip to main content

baml-cli init

Initialize a new BAML project with directory structure and configuration files.

Usage​

baml-cli init [OPTIONS]

Options​

OptionDescriptionDefault
--dest <PATH>Where to initialize the project. (current directory)
--client-type <TYPE>BAML client type to generateAuto-detected
--openapi-client-type <TYPE>OpenAPI client generatorNone

Description​

The init command:

  1. Creates ${DEST}/baml_src directory structure
  2. Creates generators.baml with initial configuration
  3. Includes example files to get started

Client Types​

TypeDescription
python/pydanticPython with Pydantic
typescriptTypeScript
goNative Go (recommended)
ruby/sorbetRuby with Sorbet
rest/openapiREST with OpenAPI

Examples​

# Initialize in current directory
baml init

# Initialize in specific directory
baml init --dest /path/to/my/project

# Initialize for Python
baml init --client-type python/pydantic

# Initialize for Go
baml init --client-type go

# Initialize with OpenAPI + Go client
baml init --client-type rest/openapi --openapi-client-type go

Notes​

  • Fails if baml_src directory already exists
  • OpenAPI generator detection: checks for openapi-generator, openapi-generator-cli, or uses npx @openapitools/openapi-generator-cli

See Also​