> 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. # What is baml_client? **baml\_client** is the code that gets generated from your BAML files that transforms your BAML prompts into the same equivalent function in your language, with validated type-safe outputs. ![](/_fern-img/6a5a6f26e4b20863fac7e1db990827ab71ebcdfcf34ecf1ecfed3fe02bcfbd8c.webp) **`Python`** ```python Python from baml_client import b resume_info = b.ExtractResume("....some text...") ``` This has all the boilerplate to: 1. call the LLM endpoint with the right parameters, 2. parse the output, 3. fix broken JSON (if any) 4. return the result in a nice typed object. 5. handle errors In Python, your BAML types get converted to Pydantic models. In Typescript, they get converted to TypeScript types, and so on. **BAML acts like a universal type system that can be used in any language**. ### Generating baml\_client Refer to the **[Installation](/guide/installation-language/python)** guides for how to set this up for your language, and how to generate it. But at a high-level, you just include a [generator block](/ref/baml/generator) in any of your BAML files. **`Python`** ```baml Python generator target { // Valid values: "python/pydantic", "typescript", "ruby/sorbet", "go" 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.203.1" } ``` **`TypeScript`** ```baml TypeScript generator target { // Valid values: "python/pydantic", "typescript", "ruby/sorbet", "go" 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.203.1" } ``` **`Go`** ```baml Go generator target { // Valid values: "python/pydantic", "typescript", "ruby/sorbet", "go" 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.203.1" // Go module name for the generated client client_package_name "example.com/myproject" // Commands to run after code generation (mandatory as it cleans up the generated code) on_generate "gofmt -w . && goimports -w . && go mod tidy" } ``` **`Ruby (beta)`** ```baml Ruby (beta) generator target { // Valid values: "python/pydantic", "typescript", "ruby/sorbet", "go" 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.203.1" } ``` **`OpenAPI`** ```baml OpenAPI generator target { // Valid values: "python/pydantic", "typescript", "ruby/sorbet", "go", "rest/openapi" 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.203.1" // '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 ." } ``` The `baml_client` transforms a BAML function into the same equivalent function in your language,