Overview
Prompt workflows load and render Jinja2 prompt templates with variables from your dataset, then execute LLM completions. This enables testing prompt variations across datasets without code changes.How It Works
- System loads prompt template by ID
- Renders template with dataset entry variables
- Calls LLM with rendered messages
- Stores output and metrics
- Runs configured evaluators
Key Benefits
- Template Reuse: Share prompts across experiments
- Variable Injection: Dynamic rendering per dataset entry
- Version Control: Track prompt versions
- Rapid Iteration: Test prompt variations without code
- Full Jinja2: Loops, conditionals, filters, macros
Configuration
Workflow Config
Type:"prompt"
Config Fields:
| Field | Type | Required | Description |
|---|---|---|---|
prompt_id | string | Yes | Prompt identifier |
Prerequisites
1. Create Prompt Template
Create a prompt with Jinja2 template and define variables: POST/api/prompts/
2. Create Prompt Version
POST/api/prompts/{prompt_id}/versions/
"string": Text variable"number": Numeric variable"object": Nested object ({{ obj.field }})"array": List variable ({% for item in items %})
3. Deploy Prompt Version
To use in experiments, prompt version must be readonly (deployed):- Create version 2 (makes version 1 readonly)
- Deploy version 1:
/api/prompts/{prompt_id}/versions/1/
Dataset Format
Input Must Contain Variables
Dataset entries must have variables matching the prompt template: Prompt Template Variables:Creating Logs with Variables
Use/api/chat/completions with prompt override:
override: truereplaces messages with rendered prompt- Variables stored in log’s input field
- Use
custom_identifierto filter logs for dataset
API Endpoints
1. Create Prompt Workflow Experiment
POST/api/v2/experiments/
Request:
2. List Execution Results
GET/api/v2/experiments/{experiment_id}/logs/list/
Response (200):
3. Get Span Tree
GET/api/v2/experiments/{experiment_id}/logs/{trace_id}/?detail=1
Response (200):
Jinja2 Template Features
Variables
Simple:Filters
String Filters:Conditionals
Loops
Simple Loop:loop.index: 1-based counterloop.index0: 0-based counterloop.first: True on first iterationloop.last: True on last iteration
Macros
Math Operations
String Concatenation
Complete Example
Step 1: Create Dataset with Variables
Step 2: Create Dataset
Step 3: Create Experiment
Step 4: Wait and View Results
Error Handling
Prompt Not Found
Error:Missing Variables
Error:Template Syntax Error
Error:Best Practices
1. Define All Variables
Declare all variables in prompt version schema:2. Use Default Values
Handle missing variables gracefully:3. Test Templates First
Test prompt rendering before creating experiments: POST/api/chat/completions
4. Version Prompts
Create new versions for experiments to compare:- Version 1: Original prompt
- Version 2: Refined prompt
- Version 3: A/B test variant
5. Use Descriptive Names
Troubleshooting
No Logs Created
Causes:- Prompt not deployed (not readonly)
- Dataset entries missing variables
- Experiment still processing in background
Span Tree Missing load_prompt
Expected:Variables Not Rendering
Symptom: Template shows{{ name }} instead of value
Cause: Variables not in dataset entry
Solution:
See Also
- API Reference - Complete endpoint documentation
- Workflows Overview - Compare workflow types
- Completion Workflow - Direct LLM completions
- Complete Example Notebook
- Jinja2 Documentation - Official Jinja2 docs