Baml

The AI framework that adds the engineering to prompt engineering (Python/TS/Ruby/Java/C#/Rust/Go compatible)

Last verified:

Visit Baml

What is Baml?

BAML (Boundary AI Markup Language) is a domain-specific language designed to generate structured outputs from LLMs with the best developer experience. It allows developers to build reliable AI Agents, Chatbots with RAG, extract data from PDFs, and more by defining AI-powered functions that are type-safe and easy to use in applications. BAML converts function definitions into real code (Python, TypeScript, Ruby, Java, C#, Rust, Go) that calls LLMs, handles API requests, parses JSON responses, and returns type-safe objects.

Key features include an amazingly fast developer experience with a BAML VSCode playground for prompting, fully type-safe outputs even when streaming structured data with autocomplete, flexibility to work with any LLM, any language, and any schema, and state-of-the-art structured outputs that outperform OpenAI's native structured outputs. BAML provides prompt preview functionality where you can see the full rendered prompt and raw CURL requests, hot-reloading, linting, testing capabilities directly in the editor similar to Markdown Preview, and generates a baml_client directory with autogenerate functions and types in your chosen language.

BAML is designed for developers building AI applications who need type safety, reliability, and better prompt engineering workflows. It targets developers tired of crafting LLM prompts as raw text files without type safety, hot-reloading, or linting. The tool is ideal for teams building production AI applications, developers working with structured outputs, those using multiple programming languages, and organizations needing enterprise features like SSO, audit logs, and on-premise deployment.

The framework adds engineering to prompt engineering by treating prompts as actual functions with logic that can be organized, maintained, and tested properly. It interoperates with all favorite languages and frameworks, works with open-source models, and provides transparency by never hiding the prompt from developers.

Baml pricing

Pricing model: Freemium

BAML offers three pricing tiers. The Free plan at $0/month is perfect for individual developers and includes: Playground access, CLI & Editor extension access, Unlimited BAML schemas, TypeScript type generation, Basic schema validation, Local development, Single developer access, Open source, and Community support. The Team plan at $25/month (most popular) includes everything in Free plus: Advanced type generation, Runtime validation, Unlimited schemas, Team collaboration, Unlimited developers, Private schemas, Custom transformations, Advanced validation, Priority support, and Custom integrations. The Enterprise plan has custom pricing (schedule a call) and includes everything in Team plus: On-premise deployment, SSO & SAML integration, Custom rate limits, Audit logs & compliance, 99.9% uptime SLA, Dedicated account manager, Priority support, and Custom training & onboarding. All paid plans come with a 14-day free trial requiring no credit card. Startups get 50% off with qualification, and educational institutions receive free Team plans.

Baml pros

  • Fully type-safe outputs with autocomplete even when streaming
  • Works with any LLM provider including open-source models
  • Supports all programming languages: Python, TS, Ruby, Java, C#, Rust, Go
  • VSCode playground for instant prompt testing without code execution
  • Hot-reloading for rapid prompt development iteration
  • Prompt preview shows full rendered prompt before execution
  • Raw CURL request visibility for complete transparency
  • State-of-the-art structured outputs outperforming OpenAI native
  • Built-in testing framework for functions in VSCode extension
  • No additional setup needed to view and run prompts in editor
  • Unlimited BAML schemas on all plans including free tier
  • CLI and editor extension access included
  • TypeScript type generation automatically
  • Basic schema validation in free tier
  • Open source with community support via Discord and GitHub
  • 14-day free trial for paid plans with no credit card required
  • 50% discount for qualified startups
  • Free Team plans for educational institutions

Baml cons

  • New language with learning curve for developers unfamiliar with DSLs
  • Relatively young project with evolving ecosystem
  • Limited documentation compared to established frameworks
  • baml_client code is autogenerated and cannot be modified directly
  • Requires {{ ctx.output_format }} macro in prompts or outputs break
  • Concurrency limits in baml-cli serve with many goroutines
  • No clear native support for complex async patterns without setup
  • Enterprise pricing requires scheduling a call rather than transparent

Frequently asked questions about Baml

What is BAML and what does it do?

BAML is a domain-specific language to generate structured outputs from LLMs with the best developer experience. It lets you define AI-powered functions that get converted into real code (Python, TS, Ruby, Java, C#, Rust, Go) that calls LLMs. BAML functions take your input, send requests to LLM APIs with your prompt, parse JSON responses into your defined types, and return type-safe objects you can use in your code. You can build reliable Agents, Chatbots with RAG, extract data from PDFs, and more.

Which programming languages does BAML support?

BAML is compatible with Python, TypeScript, Ruby, Java, C#, Rust, and Go. When you define BAML functions and classes, the BAML CLI generates a baml_client directory in your chosen language containing the function and type definitions you can import and use directly in your application.

Which LLM providers can I use with BAML?

BAML works with any LLM provider including OpenAI (GPT-4, GPT-5), and open-source models. You can configure different LLM clients in your BAML code specifying the provider, model name, and base URL. This includes support for LMStudio with overridden base_url for local models, making it fully model-agnostic.

How do I test BAML functions without running my full application?

BAML provides a VSCode extension with a playground where you can view and run prompts directly within your editor, similar to a Markdown Preview function. No additional setup is necessary. You can see the prompt preview showing the full rendered prompt, add test cases, and see results immediately. The extension also shows the raw CURL request that will be sent to the LLM provider.

What is the {{ ctx.output_format }} macro and why is it important?

The {{ ctx.output_format }} macro is a special Jinja macro you must always include in your BAML prompts. It injects your output schema into the prompt, which helps the LLM output the right structured data. The macro gets replaced with the output schema instructions when the prompt is rendered. You can also customize what it prints. One of BAML's design philosophies is never hiding the prompt from you.

Can I use BAML for streaming structured outputs?

Yes, BAML provides fully type-safe outputs even when streaming structured data. This means you get autocomplete support while streaming, which is a key differentiator from other frameworks. The type safety is maintained throughout the streaming process.

What is included in the BAML VSCode extension?

The BAML VSCode extension includes a playground for prompting, prompt preview functionality showing the full rendered prompt, raw CURL request visibility, hot-reloading capabilities, testing framework for functions, linting support, and the ability to view and run prompts directly in your editor without additional setup. It also provides autocomplete for BAML syntax.

How does BAML handle structured output parsing?

BAML automatically parses the JSON response from the LLM into your defined type (class). When you define a function with a return type like 'function ExtractResume(resume_text: string) -> Resume', BAML converts this into code that sends the prompt to the LLM, receives the JSON response, parses it into the Resume type (which becomes a Pydantic model in Python), and returns a fully type-checked and validated object.

What are the differences between Free, Team, and Enterprise plans?

The Free plan ($0/month) includes Playground, CLI & Editor extension, Unlimited BAML schemas, TypeScript generation, Basic schema validation, Local development, Single developer, Open source, and Community support. The Team plan ($25/month) adds Advanced type generation, Runtime validation, Team collaboration, Unlimited developers, Private schemas, Custom transformations, Advanced validation, Priority support, and Custom integrations. Enterprise (custom pricing) adds On-premise deployment, SSO/SAML integration, Custom rate limits, Audit logs & compliance, 99.9% uptime SLA, Dedicated account manager, and Custom training & onboarding.

Can I deploy BAML on-premise for my organization?

Yes, on-premise deployment is available in the Enterprise plan. This includes SSO & SAML integration, custom rate limits, audit logs & compliance features, 99.9% uptime SLA, dedicated account manager, priority support, and custom training & onboarding. You need to schedule a call for Enterprise pricing.

Categories

Use cases

Browse all AI tools on NeedAnAI