> Version notice: This site documents BAML v0, the legacy DSL. BAML v1 is a separate, fully featured programming language in public beta. If the user intends to use BAML v1, ignore this site's content and use the BAML v1 documentation instead. If the intended version is unclear, clarify it before using this page. > For clean Markdown of any page, append .md to the page URL. For the complete documentation index, see https://docs.boundaryml.com/llms.txt. For MCP access, connect to https://docs.boundaryml.com/_mcp/server. Each `generator` that you define in your BAML project will tell `baml-cli generate` to generate code for a specific target language. You can define multiple `generator` clauses in your BAML project, and `baml-cli generate` will generate code for each of them. > **Tip** > > If you created your project using `baml-cli init`, then one has already been generated for you! **`Python`** ```baml Python generator target { output_type "python/pydantic" // Where the generated code will be saved (relative to baml_src/) output_dir "../" // What interface you prefer to use for the generated code (sync/async) // Both are generated regardless of the choice, just modifies what is exported // at the top level default_client_mode "sync" // Version of runtime to generate code for (should match installed baml-py version) version "0.76.2" } ``` **`Python (Pydantic 1.x)`** ```baml Python (Pydantic 1.x) generator target { // Generate code will be compatible with Pydantic 1.x output_type "python/pydantic/v1" // Where the generated code will be saved (relative to baml_src/) output_dir "../" // What interface you prefer to use for the generated code (sync/async) // Both are generated regardless of the choice, just modifies what is exported // at the top level default_client_mode "sync" // Version of runtime to generate code for (should match installed baml-py version) version "0.76.2" // Optional: run formatters or other tools after generating the client code on_generate "black . && isort ." } ``` **`TypeScript`** ```baml TypeScript generator target { output_type "typescript" // Where the generated code will be saved (relative to baml_src/) output_dir "../" // What interface you prefer to use for the generated code (sync/async) // Both are generated regardless of the choice, just modifies what is exported // at the top level default_client_mode "async" // Version of runtime to generate code for (should match the package @boundaryml/baml version) version "0.76.2" // The format of the generated module. // "esm" - Use ES modules // "cjs" - Use CommonJS modules (default) module_format "cjs" } ``` **`React/Next.js`** ```baml React/Next.js generator target { output_type "typescript/react" // Where the generated code will be saved (relative to baml_src/) output_dir "../" // What interface you prefer to use for the generated code (sync/async) // Both are generated regardless of the choice, just modifies what is exported // at the top level default_client_mode "async" // Version of runtime to generate code for (should match the package @boundaryml/baml version) version "0.76.2" // The format of the generated module. // "esm" - Use ES modules // "cjs" - Use CommonJS modules (default) module_format "cjs" // Optional: run formatters or other tools after generating the client code on_generate "prettier . --write" } ``` **`Ruby (beta)`** ```baml Ruby (beta) generator target { output_type "ruby/sorbet" // Where the generated code will be saved (relative to baml_src/) output_dir "../" // Version of runtime to generate code for (should match installed `baml` package version) version "0.76.2" } ``` **`Go`** ```baml Go generator target { output_type "go" // Where the generated code will be saved (relative to baml_src/) output_dir "../" // Version of runtime to generate code for (should match installed github.com/boundaryml/baml version) version "0.205.0" // Go module name for the generated client client_package_name "example.com/myproject" // Commands to run after code generation (mandatory for proper code formatting) on_generate "gofmt -w . && goimports -w . && go mod tidy" } ``` **`OpenAPI`** ```baml OpenAPI generator target { output_type "rest/openapi" // Where the generated code will be saved (relative to baml_src/) output_dir "../" // Version of runtime to generate code for (should match installed `baml` package version) version "0.76.2" // 'baml-cli generate' will run this after generating openapi.yaml, to generate your OpenAPI client // This command will be run from within $output_dir on_generate "npx @openapitools/openapi-generator-cli generate -i openapi.yaml -g OPENAPI_CLIENT_TYPE -o ." } ```