init
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.
Usage
Options
Description
The init
command performs the following actions:
- Creates a new BAML project structure in
${DEST}/baml_src
. - Creates a
generators.baml
file in thebaml_src
directory with initial configuration. - Includes some additional examples files in
baml_src
to get you started.
Client Types
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 clientsruby/sorbet
: For Ruby clients using Sorbetrest/openapi
: For REST clients using OpenAPI
If not specified, it uses the default from the runtime CLI configuration.
OpenAPI Client Types
When using --client-type=rest/openai
, you can specify the OpenAPI client generator using the --openapi-client-type
option. Some examples include:
go
java
php
ruby
rust
csharp
For a full list of supported OpenAPI client types, refer to the OpenAPI Generator documentation.
Examples
-
Initialize a BAML project in the current directory with default settings:
-
Initialize a BAML project in a specific directory:
-
Initialize a BAML project for Python with Pydantic:
-
Initialize a BAML project for OpenAPI with a Go client:
Notes
- If the destination directory already contains a
baml_src
directory, the command will fail to prevent overwriting existing projects. - The command attempts to infer the OpenAPI generator command based on what’s available in your system PATH. It checks for
openapi-generator
,openapi-generator-cli
, or falls back to usingnpx @openapitools/openapi-generator-cli
. - After initialization, follow the instructions provided in the console output for language-specific setup steps.
For more information on getting started with BAML, visit the BAML documentation.