Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsApr 1, 2026·2 min de lecture

BAML — Type-Safe AI Function Framework

BAML adds engineering to prompt engineering with type-safe structured outputs. 7.8K+ stars. Python/TS/Ruby/Java, guaranteed schemas. Apache 2.0.

Introduction

BAML (Basically A Made-up Language) is a domain-specific language for defining AI functions with strict type contracts. Instead of wrestling with JSON parsing, regex extraction, or hoping your LLM returns the right format, BAML guarantees it.

Key capabilities:

  • Type-safe outputs: Define schemas in .baml files, get typed objects in your code
  • Multi-language: Generate clients for Python, TypeScript, Ruby, and Java from one .baml source
  • Any LLM provider: OpenAI, Anthropic, Google, Ollama, Azure — swap with one line
  • VS Code playground: Test prompts live with real-time type checking
  • Streaming with types: Stream partial results that are still type-safe
  • Retry & fallback: Built-in retry logic with provider fallback chains
  • Image & audio inputs: Multimodal support out of the box

FAQ

Q: How is this different from Instructor or Pydantic AI? A: BAML is a dedicated DSL, not a Python library. You define schemas once in .baml and generate type-safe clients for any language. It also handles retries, streaming, and provider switching declaratively.

Q: Does it work with Claude? A: Yes. Supports Anthropic Claude, OpenAI, Google Gemini, Ollama, Azure OpenAI, and any OpenAI-compatible API.

Q: What about complex nested types? A: Fully supported — arrays, optionals, enums, unions, nested classes, recursive types. The type system is richer than JSON Schema.

Works With

  • Claude Code, Cursor, Codex (via generated Python/TS clients)
  • VS Code (official BAML extension with playground)
  • Any LLM: OpenAI, Anthropic, Google, Ollama, Azure
  • Python, TypeScript, Ruby, Java
🙏

Source et remerciements

Discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires