baml-integration

Converts unstructured LLM outputs into typed, Pydantic-compatible Python data models via .baml definitions and generated baml_client code.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/trust-chain-organization/polibase --skill baml-integration
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: baml-integration
Source: https://github.com/trust-chain-organization/polibase/tree/main/.claude/skills/baml-integration
Command: npx skills add https://github.com/trust-chain-organization/polibase --skill baml-integration

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides knowledge and best practices for integrating BAML (Boundary ML) with Sagebase, including BAML definition creation, client regeneration, Factory Pattern implementation, and hybrid design approaches.

Core Features & Use Cases

  • BAML File Structure: Organized BAML definitions and generated client code layout for maintainability.
  • Code Generation: Streamlined creation of the baml_client from baml_src definitions, reducing manual coding.
  • Hybrid & Factory Patterns: Efficient strategies combining fast-rule matching with BAML for complex cases, and dynamic switching via a factory.

Quick Start

To begin, create or modify BAML definitions in baml_src/, generate the client with the recommended tool, and then use the generated baml_client to run matches and validations.

Frequently Asked Questions about baml-integration

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

FAQPage Schema
How do I convert unstructured LLM outputs into type-safe data models?▼

Type-safe conversion of LLM outputs uses BAML to define structured schemas that generate type-checked client code. Create .baml definitions in baml_src/, generate the baml_client, and use it to parse and validate LLM responses into Pydantic-compatible types, eliminating manual parsing and type errors.

What's the best way to organize BAML files for maintainability?▼

Organize BAML definitions in baml_src/ with clear schema and prompt separation, then generate the baml_client into a dedicated output directory. This centralized structure keeps prompt and schema management in one place, reduces duplication, and makes regeneration straightforward as requirements change.

How do I use the factory pattern with BAML for hybrid matching workflows?▼

The factory pattern combines fast rule-based matching for simple cases with BAML for complex ones, routing dynamically at runtime. Define both rule logic and BAML schemas, then use a factory to select the appropriate handler based on input characteristics, balancing speed and accuracy.

Can I integrate BAML with Pydantic models directly?▼

BAML generates Pydantic-compatible type definitions natively, enabling direct integration with Pydantic validation pipelines. The generated baml_client output types work seamlessly with Pydantic schemas, supporting token-efficient prompts and robust LLM output parsing without additional conversion layers.

What happens when BAML client code needs to be regenerated after schema changes?▼

Regenerate the baml_client from updated baml_src/ definitions using the recommended generation tool. The new client reflects schema changes immediately, ensuring type safety across your application and preventing stale type definitions from causing runtime errors.