PromptsMay 11, 2026·2 min read

BAML — Schema-First Prompting for Agents

BAML treats prompts as typed functions for reliable outputs. Install `baml-py`, define `.baml` functions, then call generated clients from Python.

Agent ready

Ready-to-run agent install

This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.

Native · 96/100Policy: allow
Agent surface
Any MCP/CLI agent
Kind
Prompt
Install
Single
Trust
Trust: Established
Entrypoint
Asset
Direct install command
npx -y tokrepo@latest install b858ed4b-d059-4634-b406-35e6ec9c5eca --target codex

Run after dry-run confirms the install plan.

Intro

BAML treats prompts as typed functions for reliable outputs. Install baml-py, define .baml functions, then call generated clients from Python.

  • Best for: teams iterating on prompts daily who want typesafety, streaming, and retry-friendly workflows without rewriting the whole app
  • Works with: BAML .baml files, Python via baml-py, and multi-language clients (per repo)
  • Setup time: 15 minutes

Quantitative Notes

  • PyPI package: baml-py (verified via pip index)
  • Setup time ~15 minutes
  • GitHub stars (verified): see Source & Thanks

Practical Notes

Adopt BAML when your bottleneck is iteration speed and output stability. Model your prompt as a function: inputs are typed, outputs are typed, and the prompt body is versionable. Keep a small library of BAML functions (extract, classify, route, summarize) and test them in your IDE before wiring them into agents. Over time, you get a maintainable prompt surface instead of a pile of ad-hoc strings.

Safety note: Keep function signatures small; overly generic types and huge prompts slow iteration and reduce reliability.

FAQ

Q: Do I need to write my whole app in BAML? A: No. The repo emphasizes using BAML for prompts/functions and wiring it into your existing app.

Q: What makes it different from plain prompting? A: You define a function signature with types and let the tool enforce output structure, retries, and streaming-friendly interfaces.

Q: Is it Python-only? A: No. The repo lists Python, TypeScript, Ruby, Go, and more client options via generated clients or REST patterns.


🙏

Source & Thanks

GitHub: https://github.com/BoundaryML/baml Owner avatar: https://avatars.githubusercontent.com/u/124114301?v=4 License (SPDX): Apache-2.0 GitHub stars (verified via api.github.com/repos/BoundaryML/baml): 8,206

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets