# Prompty

> A markdown file format for LLM prompts, with runtimes in several languages and a VS Code extension

- Category: App Orchestration / Prompt Programming
- Language: Python, TypeScript, Rust, C#
- Licence: MIT
- Repository: https://github.com/microsoft/prompty
- Website: https://prompty.ai
- Canonical page: https://ai-tldr.dev/tools/prompty/
- Updated: 2026-09-10

## In short

Prompty is an open-source project from Microsoft that defines a markdown file format, .prompty, for LLM prompts. It sits in the Prompt Programming category of the App Orchestration tools and is open-source, written in Python, TypeScript, Rust, C# and licensed MIT. To get started: write a .prompty file.

## Overview

Prompty is an open-source project from Microsoft that defines a markdown file format, .prompty, for LLM prompts. A .prompty file has two parts: YAML frontmatter that holds the model configuration, inputs and tools, and a markdown body that holds the prompt itself, split into messages by system:, user: and assistant: role markers and filled in with Jinja2 or Mustache template syntax.

The idea is to write a prompt once and run it anywhere Prompty runs. The same file can be executed from the VS Code extension or from a language runtime: packages exist for Python, TypeScript, Rust and C#, with Java, Go and Swift runtimes in the repo, and the runtimes are kept aligned by shared generated model types and cross-runtime conformance vectors. Each runtime runs the same pipeline: load the file, render the template, parse it into messages, execute the call against a provider (OpenAI, Microsoft Foundry or Anthropic) and process the response.

Prompty v2 adds an agentic turn runtime on top of the plain prompt asset. Tools are declared in the frontmatter, the actual functions are bound in host code, and calling turn() instead of invoke() lets the model loop through tool calls before returning a final answer, with guardrails, retries, cancellation, context budgets and memory handled in code rather than prompt text. Every render, parse, model call and tool call can be written to a trace file for inspection.

## What it does

- One .prompty file holds the model config, inputs, tools and the prompt body, using YAML frontmatter plus markdown with system/user/assistant role markers
- Jinja2 or Mustache templating, plus ${env:VAR}, ${env:VAR:default} and ${file:path.json} references for secrets and data
- Runtimes for Python, TypeScript, Rust and C# (with Java, Go and Swift in the repo), kept aligned by shared conformance vectors
- Providers for OpenAI, Microsoft Foundry and Anthropic; the openai provider can also target any OpenAI-compatible endpoint via model.connection.endpoint
- VS Code extension with New Prompty scaffolding, live preview, a connections sidebar, chat mode with tool calling and F5 to run
- Every execution writes a .tracy trace showing render, parse, execute and process steps with timing, token counts and payloads

## Getting started

Write a .prompty file, then run it from Python, TypeScript or VS Code. The commands and code below are taken from the project README.

1. Write a .prompty file

   Put the model and template settings in the frontmatter and the prompt in the body. The API key is read from an environment variable.

```yaml
---
name: greeting
model:
  id: gpt-4o-mini
  provider: openai
  connection:
    kind: key
    apiKey: ${env:OPENAI_API_KEY}
template:
  format:
    kind: jinja2
  parser:
    kind: prompty
---
system:
You are a friendly assistant.

user:
Say hello to {{name}}.
```

2. Install the Python runtime

   Install the package with the Jinja2 and OpenAI extras (other extras: foundry, anthropic, or all).

```bash
uv pip install "prompty[jinja2,openai]"
```

3. Run it from Python

   Invoke the file with its inputs.

```python
import prompty

result = prompty.invoke("greeting.prompty", inputs={"name": "Jane"})
print(result)
```

4. Or run it from TypeScript

   Install the core package plus a provider package with npm install @prompty/core @prompty/openai; importing the provider registers it.

```ts
import { invoke } from "@prompty/core";
import "@prompty/openai";

const result = await invoke("greeting.prompty", { name: "Jane" });
console.log(result);
```

5. Or run it in VS Code

   With the Prompty extension installed, open the .prompty file and press F5. Right-click in the explorer and choose New Prompty to scaffold a new file; prompts with a thread input open an interactive chat panel.

6. Step through the pipeline

   invoke() runs the whole load, render, parse, execute, process pipeline; the step-by-step functions let you inspect the messages before sending them.

```python
agent = prompty.load("my-prompt.prompty")
messages = prompty.prepare(agent, inputs={...})
result = prompty.run(agent, messages)
```

7. Let the model call tools with turn()

   Declare tools in the frontmatter, bind the real functions in code, and call turn() so the runtime loops through tool calls until the model returns a final answer.

```python
from prompty import turn

result = turn(
    "agent.prompty",
    inputs={"question": "What's the weather in Seattle?"},
    tools={"get_weather": get_weather},
)
```

## When to use it

- Keeping prompts as versioned files in a repo, with model settings and inputs next to the prompt text instead of buried in application code
- Sharing the same prompt asset between a Python service, a TypeScript app and other runtimes without rewriting it
- Iterating on a prompt inside VS Code with live preview, chat mode and a trace viewer before wiring it into an app
- Building small tool-calling agents whose tools, memory and guardrails are declared once and run on any Prompty runtime

## Version history

- 2026-09-10 python/2.0.0: The Python runtime graduated to 2.0.0, bringing the v2 rebuild with agent-loop resilience, context compaction, agent memory and structured result casting.
