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
  • Client Types
  • OpenAPI Client Types
  • Examples
  • Notes
baml-cli

init

Was this page helpful?
Edit this page
Previous

generate

Next
Built with

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

baml-cli init [OPTIONS]

Options

OptionDescriptionDefault
--dest <PATH>Specifies where to initialize the BAML projectCurrent directory (.)
--client-type <TYPE>Type of BAML client to generateGuesses 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=openapiNone

Description

The init command performs the following actions:

  1. Creates a new BAML project structure in ${DEST}/baml_src.
  2. Creates a generators.baml file in the baml_src directory with initial configuration.
  3. 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 Pydantic
  • typescript: For TypeScript clients
  • go: For native Go clients (recommended for Go projects)
  • ruby/sorbet: For Ruby clients using Sorbet
  • rest/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

  1. Initialize a BAML project in the current directory with default settings:

    baml init
  2. Initialize a BAML project in a specific directory:

    baml init --dest /path/to/my/project
  3. Initialize a BAML project for Python with Pydantic:

    baml init --client-type python/pydantic
  4. Initialize a BAML project for OpenAPI with a Go client:

    baml init --client-type openapi --openapi-client-type go
  5. Initialize a BAML project with native Go client (recommended):

    baml init --client-type go

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 using npx @openapitools/openapi-generator-cli.
  • After initialization, follow the instructions provided in the console output for language-specific setup steps.