For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Help on Discord
HomeGuideExamplesBAML ReferencePlaygroundAgents.mdChangelog
HomeGuideExamplesBAML ReferencePlaygroundAgents.mdChangelog
    • Overview
  • baml-cli
    • init
    • generate
    • test
    • serve
    • dev
    • fmt
  • Language Reference
    • Types
    • function
    • test
    • template_string
    • client<llm>
    • class
    • enum
    • generator
  • Generated baml_client
    • with_options(..)
    • AbortSignal / Cancellation
    • Collector
    • logging / env vars
    • AsyncClient / SyncClient
    • TypeBuilder
    • ClientRegistry
    • client Option
    • OnTick
    • Multimodal
    • Image
    • Audio
    • Pdf
    • Video
  • Attributes
    • What are attributes?
    • @alias / @@alias
    • @description / @@description
    • @skip
    • @assert
    • @check
    • Jinja in Attributes
    • @@dynamic
  • LLM Client Providers
    • Overview
    • AWS Bedrock
    • Anthropic
    • Google AI: Gemini
    • Google: Vertex
    • OpenAI
    • OpenAI Responses API
    • OpenAI from Azure
    • OpenRouter
    • openai-generic
    • Microsoft Foundry (openai-generic)
    • Cerebras (openai-generic)
    • Groq (openai-generic)
    • Hugging Face (openai-generic)
    • Keywords AI (openai-generic)
    • Llama API (openai-generic)
    • Litellm (openai-generic)
    • LM Studio (openai-generic)
    • Ollama (openai-generic)
    • Vercel AI Gateway (openai-generic)
    • Tinfoil (openai-generic)
    • TogetherAI (openai-generic)
    • Unify AI (openai-generic)
    • vLLM (openai-generic)
  • LLM Client Strategies
    • Timeout Configuration
    • Retry Policy
    • Fallback
    • Round Robin
  • Prompt Syntax
    • What is jinja?
    • Jinja Filters
    • ctx.output_format
    • ctx.client
    • _.role
    • Variables
    • Conditionals
    • Loops
  • Editor Extension Settings
    • baml.cliPath
    • baml.generateCodeOnSave
    • baml.enablePlaygroundProxy
    • baml.syncExtensionToGeneratorVersion
Help on Discord
LogoLogo
On this page
  • Usage
  • Options
  • Description
  • Examples
  • Output
  • Notes
baml-cli

generate

Was this page helpful?
Edit this page
Previous

test

Next
Built with

The generate command is used to generate BAML clients based on your BAML source files. It processes the BAML configurations and creates the necessary client code for your specified output type.

Usage

baml-cli generate [OPTIONS]

Options

OptionDescriptionDefault
--from <PATH>Path to the baml_src directory./baml_src
--no-version-checkGenerate baml_client without checking for version mismatchfalse
--no-testsStrip test blocks from inlined BAML to reduce generated file sizefalse

Description

The generate command performs the following actions:

  1. Finds all generators in the BAML project (usualy in generators.baml).
  2. Ensure all generators match the CLI version.
  3. Generate each baml_client based on the generator configurations.

Examples

  1. Generate clients using default settings:

    baml-cli generate
  2. Generate clients from a specific directory:

    baml-cli generate --from /path/to/my/baml_src
  3. Generate clients without version check:

    baml-cli generate --no-version-check
  4. Generate clients without test blocks (reduces file size):

    baml-cli generate --no-tests

Output

The command provides informative output about the generation process:

  • If no clients were generated, it will suggest a configuration to add to your BAML files.
  • If clients were generated, it will report the number of clients generated and their locations.

Notes

  • If no generator configurations are found in the BAML files, the command will generate a default client based on the CLI defaults and provide instructions on how to add a generator configuration to your BAML files.
  • If generator configurations are found, the command will generate clients according to those configurations.
  • If one of the generators fails, the command will stop at that point and report the error.
  • The --no-tests flag is useful for production builds where you want to minimize the generated client size. When enabled, test blocks defined in your BAML files are not included in the generated baml_client, reducing bundle size without affecting runtime functionality.