Skip to main content
Testkube 2.15.0 is out! AI Governance, GitLab in AI Test Creation, an executions timeline, and much more! Read More

Basic Promptfoo Example

Promptfoo is a popular open source tool for evaluating and red-teaming LLM applications using declarative test cases. The Workflow below runs the official Promptfoo getting-started example, uploads the generated reports as artifacts and exports the results as metrics. You can paste this directly into the YAML of an existing or new Workflow, just make sure to update the name and namespace for your environment if needed.

  • The spec.content property checks out the getting-started example from the Promptfoo GitHub repository, pinned to the release tag that matches the Promptfoo version the Workflow runs.
  • The spec.container property defines the working directory, Node.js image, and environment variables for the Workflow; the OPENAI_API_KEY is resolved using the credential expression so the key is never stored in the Workflow definition itself.
  • The Run Promptfoo evaluation step installs the same Promptfoo version, runs the evaluation and writes both JSON and HTML reports. Its cache block keeps the npm download cache between executions, so later runs install Promptfoo from the cache; see Dependency Caching.
  • The Export metrics step runs the testkube-ai-metrics-parser image, which converts the JSON results into a results.lp file with the successes, failures, errors, pass rate, token count and duration of the evaluation.
  • The Save report step uploads the reports and the metrics file as artifacts; the always condition makes sure they are uploaded even if the evaluation fails.
Basic Promptfoo Workflow
kind: TestWorkflow
apiVersion: testworkflows.testkube.io/v1
metadata:
name: promptfoo-getting-started
namespace: testkube
labels:
docs: example
type: ai
spec:
content:
git:
uri: https://github.com/promptfoo/promptfoo.git
revision: 0.126.0
cone: true
paths:
- examples/getting-started
container:
workingDir: /data/repo/examples/getting-started
image: node:22-bookworm-slim
env:
- name: HOME
value: /data
- name: npm_config_cache
value: /root/.npm
- name: PROMPTFOO_DISABLE_TELEMETRY
value: "1"
- name: CI
value: "true"
- name: OPENAI_API_KEY
value: '{{credential("OPENAI_API_KEY")}}'
resources:
requests:
cpu: 500m
memory: 1Gi
steps:
- name: Run Promptfoo evaluation
cache:
key: npm-promptfoo-0.126.0
paths:
- /root/.npm/_cacache
shell: |
set -e
npm install --global promptfoo@0.126.0
promptfoo eval -o results.json -o results.html
- name: Export metrics
condition: always
container:
image: docker.io/kubeshop/testkube-ai-metrics-parser:latest
shell: testkube-ai-metrics-parser promptfoo -i results.json -o results.lp --stdout
- name: Save report
condition: always
artifacts:
paths:
- results.json
- results.html
- results.lp

After execution, the JSON and HTML reports are available under the Artifacts tab of the execution, and the evaluation output is shown in the Log Output tab. Testkube ingests the results.lp file as custom metrics under the promptfoo_eval measurement, so you can chart the pass rate and token usage across executions in Insights.