baml icon indicating copy to clipboard operation
baml copied to clipboard

[feat] add TOON to output formats

Open phischdev opened this issue 2 months ago • 4 comments

Product

BAML

Problem Statement / Use Case

AI is becoming cheaper and more accessible, but larger context windows allow for larger data inputs as well. LLM tokens still cost money – and standard JSON is verbose and token-expensive.

Proposed Solution

„Token-Oriented Object Notation is a compact, human-readable format designed for passing structured data to Large Language Models with significantly reduced token usage.“

It claims to be a drop-in replacement for JSON that typically uses 30–60% fewer tokens.

https://github.com/johannschopplich/toon

Alternative Solutions

No response

Additional Context

No response

phischdev avatar Oct 27 '25 08:10 phischdev

BAML-524

linear[bot] avatar Oct 27 '25 08:10 linear[bot]

that would be awesome !

sneerin avatar Nov 06 '25 18:11 sneerin

I think we should implement this soon to try to reduce token cost

kienbui1995 avatar Nov 12 '25 11:11 kienbui1995

we are looking for contributors to drive this through.

We would need a spec of how to serialize BAML Types into this format in the prompt, like this document: https://gloochat.notion.site/XML-Outputs-218bb2d26216806fb4dfef242d150c51?source=copy_link

https://crates.io/crates/toon-format/0.3.0

Then we can use an opensource crate to adapt our parser to turn the TOON output into json > back to the baml parser

aaronvg avatar Nov 13 '25 18:11 aaronvg