baml-core

Write and test BAML code for typed LLM functions, agents, and AI workflows.

9|Updated Jun 4, 2026
One-click install
npx skills add https://github.com/BoundaryML/baml-demos --skill baml-core-boundaryml
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: baml-core
Source: https://github.com/BoundaryML/baml-demos/tree/main/2026-09-08-llm-switching-patterns/.agents/skills/baml-core
Command: npx skills add https://github.com/BoundaryML/baml-demos --skill baml-core-boundaryml

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building LLM-powered applications requires structured outputs, prompt management, and reliable client configuration, which is error-prone in general-purpose languages. This Skill teaches the BAML language and CLI so you can define statically-typed LLM functions where the return type is the schema, test orchestration logic offline, and generate typed SDKs for Python and TypeScript. ## Core Features & Use Cases - Typed LLM Functions: Declare functions with client: and prompt: blocks whose return type (class, enum, union) defines the structured output the model must produce. - Full Language Reference: Covers classes, enums, interfaces, pattern matching, error handling with catch/catch_all, green-thread concurrency via spawn/await, and resource safety with defer and cleanup. - CLI-Driven Workflow: Use baml describe for stdlib documentation, baml run -e for fast expression evaluation, baml check for compile-checking, and baml test for offline unit tests. - Use Case: Build an invoice extraction pipeline where an LLM function returns a typed Invoice class, then post-process line items with pure functions and unit-test the logic without making model calls. ## Quick Start Ask the AI to write a BAML function that extracts structured data from text, then compile-check it with baml check and test the pure logic with baml test.

Frequently Asked Questions about baml-core

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I get structured output from an LLM in BAML?▼

Define a BAML function whose return type is the schema, such as a class, enum, or literal union, and write a backtick prompt that injects ${ctx.output_format}. The model's response is parsed into that typed value automatically.

How do I configure LLM clients in BAML?▼

Clients are ordinary values implementing ai.Client, constructed with providers like openai.ResponsesClient.new or anthropic.AnthropicClient.new. Compose reliability by wrapping with ai.clients.Retry.new, RoundRobin, or a Fallback class literal.

Can I test BAML code without calling an LLM?▼

Yes, unit-test pure orchestration and post-processing functions on literal data using the six assert helpers in test blocks. Calling an LLM function inside a test makes a real request, so keep model calls out of offline tests.

How do I call BAML functions from Python or TypeScript?▼

Declare a generator block in baml.toml, run baml generate, then import the typed baml_sdk in your host language. Run baml describe python or baml describe typescript for setup details.

Why does integer division give wrong results in BAML?▼

BAML arithmetic is type-driven: int divided by int truncates, so 285 / 100 equals 2, not 2.85. Mix in a float operand like 100.0 to get float division, since there is no to_float method.