Skip to content

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"]
FunctionPurposeOutput
load(path)Parse a .prompty file into a typed Prompty objectPrompty
render(agent, inputs)Render instructions with input valuesrendered text
parse(agent, rendered)Convert rendered role-marked text into messagesMessage[]
prepare(agent, inputs)Validate inputs, render, parse, and expand thread markersMessage[]
run(agent, messages)Execute prepared messages and process the responseprovider-specific result
invoke(pathOrAgent, inputs)One-shot load/prepare/run flowprovider-specific result
process(agent, response)Convert a raw provider response into a clean resulttext, object, vector, image, stream, or tool call
validateInputs(agent, inputs)Apply defaults and enforce required inputsvalidated 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"})
RuntimeConvention
PythonSync functions plus _async variants, such as prepare_async()
TypeScriptAsync-first APIs returning Promise<T> where I/O or provider calls are involved
C#Async methods use the Async suffix, such as PrepareAsync()
RustPipeline functions that call renderers/providers are async and return Result<T>