Skip to content
Prompty

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 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

Parse a .prompty file into a typed Prompty object.

agent = prompty.load("chat.prompty")
print(agent.name)
print(agent.model.id)

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"})

Parse rendered text with role markers into structured messages.

messages = prompty.parse(agent, rendered)

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"})

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)

Run the full one-shot pipeline: load, prepare, execute, and process.

result = prompty.invoke("chat.prompty", inputs={"q": "Hi"})

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)

Apply defaults and raise an error when required inputs are missing.

prompty.validate_inputs(agent, {"name": "Jane"})
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>