Where to Start Using LMQL on lmql.ai

Updated

Start at the Get Started button on the lmql.ai homepage if you want a guided introduction, or open Playground if you want to try LMQL in the browser before installing anything. For reference material, go to Docs; for source code and contributions, use GitHub; for questions and community discussion, join Discord. All of these are linked directly from the site's main navigation.

What each entry point is for

Entry point Use it when you want to… What you get
Get Started Begin from zero with a guided path The site's recommended first step into LMQL
Playground Try LMQL without setting up a local environment A browser-based place to experiment
Docs Look up syntax, constraints, types, and backends The reference documentation
GitHub Read the source, report issues, or contribute The project repository
Discord Ask questions and talk to other users Community support

The homepage also links to Blog and Research if you want background on the project, and invites visitors to fill out the LMQL developer survey to help shape the next major version.

A first query to try

The homepage shows a complete example you can use as your first test. It asks a question, constrains the answer's length and ending, and then requests a typed integer:

lmql @lmql.query
def meaning_of_life():
    '''lmql
    "Q: What is the answer to life, the universe and everything?"
    "A: [ANSWER]"
    where len(ANSWER) < 120 and STOPS_AT(ANSWER, ".")

    print("LLM returned", ANSWER)

    "The answer is [NUM: int]"
    return NUM
    '''

Called from Python as meaning_of_life(), the documented result is 42. Two things are worth noticing: the where clause enforces a hard constraint on the generated text, and [NUM: int] guarantees the output format rather than hoping the model complies.

What LMQL adds over plain prompts

The site describes LMQL as "a programming language for LLMs" for "robust and modular LLM prompting using types, templates, constraints and an optimizing runtime." In practice that means:

  • Constraints — conditions like STOPS_AT and length limits are enforced by the runtime, not left to the model.
  • Types and regex — typed variables such as [NUM: int] guarantee output format.
  • Python control flow — loops and string interpolation build prompts programmatically; the packing-list example uses a for loop with a where THING in [...] constraint.
  • Nested queries — the site highlights this as a newer feature for modular, reusable prompt components.
  • Backend portability — LMQL "automatically makes your LLM code portable across several backends," switchable with a single line. The listed backends are llama.cpp, OpenAI, and Hugging Face Transformers.

Practical starting order

  1. Open Playground and run a short query to see constrained generation in action.
  2. Read Get Started for the setup path that fits your environment.
  3. Keep Docs open for syntax and backend configuration as you write your own queries.
  4. Move to GitHub when you need the code locally or want to contribute.
  5. Use Discord when something in the docs doesn't match what you see.

The site does not state pricing or login requirements for these entry points, so check each page directly if access terms matter for your use.