Skip to content

Getting Started

Prompty is a markdown file format for LLM prompts. A .prompty file combines structured YAML frontmatter (model config, inputs, tools) with a markdown body that becomes the prompt instructions. The runtime loads, renders, parses, and executes these files.

flowchart LR
    subgraph file["greeting.prompty"]
        frontmatter["YAML frontmatter<br/><br/>name<br/>model + connection<br/>inputs / outputs<br/>tools<br/>template config"]
        body["Markdown body<br/><br/>role markers<br/>instructions<br/>template variables"]
    end

    frontmatter --> loaded["typed Prompty object"]
    body --> instructions["agent instructions"]
    instructions --> render["render<br/>{{ userName }}"]
    render --> parse["parse<br/>system / user / assistant messages"]
    loaded --> execute["execute<br/>provider + model config"]
    parse --> execute
    execute --> result["processed result"]

    classDef filePart fill:#eff6ff,stroke:#2563eb,color:#1e3a8a
    classDef runtime fill:#f0fdf4,stroke:#16a34a,color:#14532d
    class frontmatter,body filePart
    class loaded,instructions,render,parse,execute,result runtime

The frontmatter is configuration. The body is the prompt. Prompty combines both: frontmatter becomes a typed runtime object, and the markdown body becomes rendered instructions that are parsed into chat messages.

Terminal window
# Core + Jinja2 renderer + OpenAI provider
uv pip install "prompty[jinja2,openai]"
# With Microsoft Foundry support
uv pip install "prompty[jinja2,foundry]"
# With Anthropic support
uv pip install "prompty[jinja2,anthropic]"
# Everything
uv pip install "prompty[all]"
ProviderPython extraTypeScript packageC# packageRust crateNotes
OpenAIprompty[openai]@prompty/openaiPrompty.OpenAIprompty-openaiDirect OpenAI and OpenAI-compatible endpoints.
Microsoft Foundryprompty[foundry]@prompty/foundryPrompty.Foundryprompty-foundryFoundry/Azure OpenAI deployments; azure remains a deprecated alias.
Anthropicprompty[anthropic]@prompty/anthropicPrompty.Anthropicprompty-anthropicClaude via Anthropic Messages API.

If you are not sure which model.id or deployment to use, see Discover Available Models.

Create a file called greeting.prompty:

---
name: greeting
description: A friendly greeting prompt
model:
id: gpt-4o-mini
provider: openai
connection:
kind: key
apiKey: ${env:OPENAI_API_KEY}
inputs:
- name: userName
kind: string
default: World
---
system:
You are a friendly assistant who greets people warmly.
user:
Say hello to {{userName}} and ask how their day is going.
import prompty
# All-in-one: load → render → parse → execute → process
result = prompty.invoke(
"greeting.prompty",
inputs={"userName": "Jane"},
)
print(result)
# "Hello Jane! 👋 How's your day going so far?"

For more control, use the pipeline stages individually:

import prompty
# 1. Load the .prompty file → typed Prompty object
agent = prompty.load("greeting.prompty")
# 2. Render template + parse → list[Message]
messages = prompty.prepare(agent, inputs={"userName": "Jane"})
# 3. Call the LLM + process → clean result
result = prompty.run(agent, messages)

Use ${env:VAR_NAME} in frontmatter to reference environment variables. Create a .env file in your project root:

Terminal window
OPENAI_API_KEY=sk-your-key-here

Prompty automatically loads .env files.

Here’s a full, tested example you can copy and run:

chat_basic.py
"""Basic chat completion with OpenAI.
This example loads a .prompty file and runs a simple chat completion.
Used in: how-to/openai.mdx, getting-started/index.mdx
"""
from __future__ import annotations
from prompty import invoke, load
agent = load("chat-basic.prompty")
result = invoke(agent, inputs={"question": "What is Prompty?"})
print(result)