IBM/prompt-declaration-language

Prompt Declaration Language (PDL) is a declarative prompt programming language.

What it solves

It addresses the difficulty of creating reliable and composable LLM prompts that can be easily integrated into software systems. Instead of hard-coding prompts, it provides a structured, declarative way to manage them, reducing the fragility of prompt engineering.

How it works

PDL uses a YAML-based declarative language to specify prompt templates, model calls, and logic. A CLI tool interprets these programs to accumulate messages and send them to hosted or local models (such as those via Ollama). It supports variables, conditionals, loops, and functions, and can integrate Python code execution and REST APIs directly within the prompt flow.

Who it’s for

Developers who need to build complex LLM-powered applications and want a structured approach to prompt engineering, debugging, and integration with traditional rule-based systems.

Highlights

  • Declarative Prompting: Uses YAML to define prompt flows, making them easier to manage than raw strings.
  • Integrated Control Flow: Supports variables, loops, and conditionals for dynamic prompt generation.
  • Hybrid Execution: Combines LLM calls with native Python code execution and API calls.
  • Developer Tooling: Includes a Python SDK, a GUI for interactive debugging and live programming, and type checking for model I/O.
  • Prompt Optimization: Offers AutoPDL, a tool for optimizing textual prompts, few-shot examples, and prompting patterns.

Related

  • Project
  • Project
  • Project
  • Project
  • Project