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
      • comments
      • Environment Variables
      • string
      • int / float
      • bool
      • array (list)
      • map (dictionary)
      • image / audio
    • 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
  • Quoted Strings
  • Unquoted Strings
  • Block Strings
  • Escape Characters
  • Adding a "#
Language ReferenceGeneral BAML Syntax

string

Was this page helpful?
Edit this page
Previous

int / float

Next
Built with

BAML treats templatized strings as first-class citizens.

Quoted Strings

This is a valid inline string, which is surrounded by double quotes. BAML processes common escape sequences inside quoted strings, including \n, \t, \\, and \".

These cannot have template variables or expressions inside them. Use a block string for that.
1"Hello World"
2
3"\n"
4"a\\b"
5"a\"b"

Unquoted Strings

BAML also supports simple unquoted in-line strings. The string below is valid! These are useful for simple strings such as configuration options.

1Hello World

Unquoted strings may not have any of the following since they are reserved characters (note this may change in the future):

  • Quotes “double” or ‘single’
  • At-signs @
  • Curlies
  • hashtags #
  • Parentheses ()
  • Brackets []
  • commas ,
  • newlines

When in doubt, use a quoted string or a block string, but the VSCode extension will warn you if there is a parsing issue.

Block Strings

If a string is on multiple lines, it must be surrounded by #” and ”#. This is called a block string.

1#"
2Hello
3World
4"#

Block strings are automatically dedented and stripped of the first and last newline. This means that the following will render the same thing as above

1#"
2 Hello
3 World
4"#

When used for templating, block strings can contain expressions and variables using Jinja syntax.

1template_string Greeting(name: string) #"
2 Hello {{ name }}!
3"#

Escape Characters

Escaped characters are injected as is into the string.

1#"\n"#

This will render as \\n in the output.

Adding a "#

To include a "# in a block string, you can prefix it with a different count of #.

1###"
2 #"Hello"#
3"###

This will render as #"Hello"#.