Streaming text is easy. Streaming typed data—where you can access fields as they arrive—that's the BAML difference.
Access partial.title before the full response is done. Build real-time UIs that show fields as they're ready.
class Article {
title string
summary string @description("2-3 sentence summary")
keyPoints string[] @description("3-5 bullet points")
sentiment Sentiment
}
enum Sentiment {
POSITIVE
NEGATIVE
NEUTRAL
}
function SummarizeArticle(url: string) -> Article {
client "openai/gpt-4o-mini"
prompt #"
Summarize the article at: {{ url }}
{{ ctx.output_format }}
"#
}