Pipeline Functions
Pipeline functions move a .prompty file from source text to model-ready
messages and then to a processed result.
flowchart LR A[".prompty file"] --> B["load"] B --> C["Prompty"] C --> D["render"] D --> E["parse"] E --> F["run"] F --> G["process"] G --> H["result"]
Function summary
Section titled “Function summary”| Function | Purpose | Output |
|---|---|---|
load(path) | Parse a .prompty file into a typed Prompty object | Prompty |
render(agent, inputs) | Render instructions with input values | rendered text |
parse(agent, rendered) | Convert rendered role-marked text into messages | Message[] |
prepare(agent, inputs) | Validate inputs, render, parse, and expand thread markers | Message[] |
run(agent, messages) | Execute prepared messages and process the response | provider-specific result |
invoke(pathOrAgent, inputs) | One-shot load/prepare/run flow | provider-specific result |
process(agent, response) | Convert a raw provider response into a clean result | text, object, vector, image, stream, or tool call |
validateInputs(agent, inputs) | Apply defaults and enforce required inputs | validated inputs or error |
load(path)
Section titled “load(path)”Parse a .prompty file into a typed Prompty object.
agent = prompty.load("chat.prompty")print(agent.name)print(agent.model.id)import { load } from "@prompty/core";
const agent = await load("chat.prompty");using Prompty.Core;
var agent = PromptyLoader.Load("chat.prompty");Console.WriteLine(agent.Name);Console.WriteLine(agent.Model.Id);let agent = prompty::load("chat.prompty")?;println!("{}", agent.name());println!("{}", agent.model().id());render(agent, inputs)
Section titled “render(agent, inputs)”Render the prompt template with input values. This returns the raw rendered text before role markers are parsed into messages.
rendered = prompty.render(agent, inputs={"q": "Hi"})import { render } from "@prompty/core";
const rendered = await render(agent, { q: "Hi" });var rendered = await Pipeline.RenderAsync(agent, new() { ["q"] = "Hi" });let rendered = prompty::render(&agent, Some(&json!({ "q": "Hi" }))).await?;parse(agent, rendered)
Section titled “parse(agent, rendered)”Parse rendered text with role markers into structured messages.
messages = prompty.parse(agent, rendered)import { parse } from "@prompty/core";
const messages = await parse(agent, rendered);var messages = await Pipeline.ParseAsync(agent, rendered);let messages = prompty::parse(&agent, &rendered).await?;prepare(agent, inputs)
Section titled “prepare(agent, inputs)”Validate inputs, render the template, parse messages, and expand thread markers. Use this when you want model-ready messages without calling a provider.
messages = prompty.prepare(agent, inputs={"q": "Hi"})import { prepare } from "@prompty/core";
const messages = await prepare(agent, { q: "Hi" });var messages = await Pipeline.PrepareAsync(agent, new() { ["q"] = "Hi" });let messages = prompty::prepare(&agent, Some(&json!({ "q": "Hi" }))).await?;run(agent, messages)
Section titled “run(agent, messages)”Execute prepared messages with the configured provider and process the response. Most runtimes also expose a raw option for callers that need the provider SDK response.
result = prompty.run(agent, messages)response = prompty.run(agent, messages, raw=True)import { run } from "@prompty/core";
const result = await run(agent, messages);var result = await Pipeline.RunAsync(agent, messages);var response = await Pipeline.RunAsync(agent, messages, raw: true);let result = prompty::run(&agent, &messages).await?;let response = prompty::run_raw(&agent, &messages).await?;invoke(pathOrAgent, inputs)
Section titled “invoke(pathOrAgent, inputs)”Run the full one-shot pipeline: load, prepare, execute, and process.
result = prompty.invoke("chat.prompty", inputs={"q": "Hi"})import { invoke } from "@prompty/core";
const result = await invoke("chat.prompty", { q: "Hi" });var result = await Pipeline.InvokeAsync("chat.prompty", new() { ["q"] = "Hi" });let result = prompty::invoke_from_path( "chat.prompty", Some(&json!({ "q": "Hi" })),).await?;process(agent, response)
Section titled “process(agent, response)”Extract clean content from a raw provider response. Processing behavior depends
on model.apiType, outputs, streaming options, and provider response shape.
result = prompty.process(agent, response)import { process } from "@prompty/core";
const result = await process(agent, response);var result = await Pipeline.ProcessAsync(agent, response);let result = prompty::process(&agent, &response).await?;validateInputs(agent, inputs)
Section titled “validateInputs(agent, inputs)”Apply defaults and raise an error when required inputs are missing.
prompty.validate_inputs(agent, {"name": "Jane"})import { validateInputs } from "@prompty/core";
validateInputs(agent, { name: "Jane" });Pipeline.ValidateInputs(agent, new() { ["name"] = "Jane" });prompty::validate_inputs(&agent, &json!({ "name": "Jane" }))?;Async naming
Section titled “Async naming”| Runtime | Convention |
|---|---|
| Python | Sync functions plus _async variants, such as prepare_async() |
| TypeScript | Async-first APIs returning Promise<T> where I/O or provider calls are involved |
| C# | Async methods use the Async suffix, such as PrepareAsync() |
| Rust | Pipeline functions that call renderers/providers are async and return Result<T> |