About LMQL
LMQL is a programming language for interacting with large language models, created by the SRI Lab at ETH Zurich and contributors. It treats prompting as code: top level strings in a query are prompts, and the model's output is captured in variables that can be constrained, typed and reused in ordinary Python.
The core idea is that constraints are enforced by the runtime rather than requested politely in the prompt. A where clause can limit the length of a generated variable, stop it at a given token, restrict it to a set of allowed values, or force an integer type so the output format is guaranteed. Queries are plain Python functions, so they can use loops, control flow and string interpolation, and they can call other queries through nested queries for modular prompt components. The project also documents tool augmentation, chatbots, meta prompting, multi part prompts and measuring distributions over outputs.
LMQL is aimed at developers who build LLM applications and want robust, repeatable output structure with fewer retries and parsing steps. It is portable across backends, including llama.cpp, OpenAI and Hugging Face Transformers, and switching between them takes a single line of code. The site offers a getting started guide, documentation and a contribution path, and it is currently asking for responses to a developer survey about the next major version.
The site publishes no pricing page and lists no paid plans.