fern/03-reference/baml-cli/init.mdx
The init command is used to initialize a project with BAML. It sets up the necessary directory structure and configuration files to get you started with BAML.
baml-cli init [OPTIONS]
| Option | Description | Default |
|---|---|---|
--dest <PATH> | Specifies where to initialize the BAML project | Current directory (.) |
--client-type <TYPE> | Type of BAML client to generate | Guesses based on where the CLI was installed from (python/pydantic for pip, typescript for npm, etc.) |
--openapi-client-type <TYPE> | The OpenAPI client generator to run, if --client-type=openapi | None |
The init command performs the following actions:
${DEST}/baml_src.generators.baml file in the baml_src directory with initial configuration.baml_src to get you started.The --client-type option allows you to specify the type of BAML client to generate. Available options include:
python/pydantic: For Python clients using Pydantictypescript: For TypeScript clientsgo: For native Go clients (recommended for Go projects)ruby/sorbet: For Ruby clients using Sorbetrest/openapi: For REST clients using OpenAPIIf not specified, it uses the default from the runtime CLI configuration.
When using --client-type=rest/openai, you can specify the OpenAPI client generator using the --openapi-client-type option. Some examples include:
gojavaphprubyrustcsharpFor a full list of supported OpenAPI client types, refer to the OpenAPI Generator documentation.
Initialize a BAML project in the current directory with default settings:
baml init
Initialize a BAML project in a specific directory:
baml init --dest /path/to/my/project
Initialize a BAML project for Python with Pydantic:
baml init --client-type python/pydantic
Initialize a BAML project for OpenAPI with a Go client:
baml init --client-type openapi --openapi-client-type go
Initialize a BAML project with native Go client (recommended):
baml init --client-type go
baml_src directory, the command will fail to prevent overwriting existing projects.openapi-generator, openapi-generator-cli, or falls back to using npx @openapitools/openapi-generator-cli.