Precise
Write generative functions using code. The @generative decorator handles the communication with the LLM.
Make outputs precise, predictable, and repeatable with Mellea’s library of generative functions.
Mellea is a Python library for working with LLMs using generative functions.
In traditional programming, functions turn inputs into deterministic outputs. Mellea builds on this by allowing functions to call LLMs to create an output, but with customizable requirements that maintain the rigor of professional software development. If an LLM returns something that doesn’t meet a requirement, Mellea will automatically try it again. This means you can build applications that make use of the power of LLMs while keeping all the benefits of reliable, testable Python code.
Write generative functions using code. The @generative decorator handles the communication with the LLM.
Set the requirements that you want Mellea to validate. Automatic retries mean unwanted outputs never reach your users.
Expose any Mellea program as an MCP tool. The calling agent gets the same validated, predictable output as other Mellea users.
Built-in Granite Guardian integration detects harmful outputs, hallucinations, and jailbreak attempts before they reach your users — no external service required.
Granite is a family of models built with enterprises in mind. It has open-weights for transparency, comes in sizes from 350M-32B parameters, and offers an extensive adapter library. This means it can take on specific tasks with the performance of a much larger model while keeping its nimble speed and low costs.
Mellea is designed to be Granite’s SDK. Together, they offer a flexible way to build AI applications that are transparent from the ground up and only do what you want them to.
Mellea v0.7.0 ships a sandboxed code interpreter, a shell tool, and a library of executable requirements, plus context compaction and plugin-based telemetry, so agents can run code and stay grounded.
Trace generation, validation, and sampling in detail. Built-in plugins reveal model calls, requirement failures, repair events, and loop iterations—all without boilerplate.
At the IBM Booth at THINK 2026, we ran a demo using every model family from the Granite 4.1 release