Langium AI

Packages
Overview
Langium AI is a suite of tools that make it easier to integrate AI applications with Langium DSLs. It provides a core library, a CLI, and a set of agent skills that together form a workflow for building, evaluating, and refining AI-powered tooling around your domain-specific language.
You can read more about Langium AI here as well, Langium AI: The fusion of DSLs and LLMs.
In particular, Langium AI helps to solve the following problems:
- Selecting good models with regards to your DSL
- Evaluating DSL output from an LLM
- Processing DSL programs as data, while respecting the structure of your DSL
- Developing good natural language interfaces for DSLs
For updates on the latest changes, check out the CHANGELOG to see what's new.
Contributions
Langium AI is made up of three main contributions:
1. langium-ai-tools
langium-ai-tools is the core library. It provides provider-agnostic building blocks that leverage your existing Langium services:
- Evaluator (
LangiumEvaluator) — validates LLM-generated DSL code against your real parser and validator, returning structured diagnostics and scores
- Splitter (
ProgramMapper, splitByNode) — chunks DSL documents by AST node type, respecting language structure, for ingestion into vector DBs or other pipelines
- Analyzer (
LangiumDocumentAnalyzer) — computes grammar rule usage, coverage, and diversity metrics across documents
- Testing API — a vitest-style API (
describe, evaluation, beforeEach, evaluation.each) for writing programmatic eval suites
- Evaluation Matrix (
EvalMatrix) — compares multiple runners (models, RAG pipelines, etc.) against test suites with configurable evaluators
npm install langium-ai-tools
See the langium-ai-tools README for full API documentation and examples.
2. langium-ai (CLI)
langium-ai is the CLI (lai) for bootstrapping and managing AI-powered tooling in Langium projects. It drives an iterative loop to refine your AI applications:
init -> generate descriptor -> refine -> generate system prompt -> evaluate -> analyze -> refine -> repeat
The LAI cli exposes a number of commands to line up quite nicely with the loop process above.
| Command | Purpose |
|---|
lai init | One-time project setup — detects Langium structure, configures LLM provider, scaffolds evals |
lai init config | Reinitialize just the lai.config.jsonc file (re-detects project structure) |
lai init evals | Reinitialize the evals/ directory and regenerate template files |
lai gen descriptor | Generate a structured YAML descriptor mapping your Langium project |
lai gen sysprompt | Synthesize a system prompt from the descriptor |
lai evaluate | Run evaluation suites against your system prompt via your configured LLM |
lai show / lai compare / lai stats / lai history | Inspect, compare, and analyze evaluation runs |
lai export / lai tag / lai clean | Export run results, tag runs, and prune old evaluation logs |
lai validate | Check descriptor schema and verify all referenced files exist |
lai status | Check project configuration status |
Setup and generation commands (init, init config, init evals, gen) accept a -y / --yes flag to skip interactive prompts and use defaults — handy for CI and other non-interactive runs. lai clean also accepts --yes to skip its deletion confirmation.