Promptfoo LLM Testing: Test-Driven Development for Language Models

Promptfoo LLM Testing: Test-Driven Development for Language Models

Promptfoo LLM testing is an open-source way to test language model applications the way software teams test code: with repeatable cases, clear pass and fail rules, and results that can run in continuous integration. Instead of trying a few prompts by hand and judging the answers by eye, you define what good output looks like, run every prompt against every model, and see which combinations pass. The central question is simple: will this prompt still work after the next change? Promptfoo answers it by making the test repeatable, so a change that breaks behaviour is caught before it reaches users.

That discipline matters because language model behaviour is fragile. A small edit to a prompt, a new model version, or a change in retrieved context can alter answers in ways that are hard to spot by reading a few examples. Promptfoo LLM testing replaces that guesswork with a matrix: prompts down one side, test cases down the other, and a score for each cell. When a cell turns red, you know exactly which prompt, model and input failed.

Key takeaways

  • Promptfoo LLM testing runs prompts against test cases with defined assertions, and scores each result.
  • Evals live in a single configuration file that can be version-controlled alongside code.
  • It compares prompts and models side by side, so regressions are visible test by test.
  • Assertions range from simple string checks to LLM-as-a-judge scoring.
  • Its red teaming features generate adversarial tests for prompt injection, jailbreaks and data leakage.

What is Promptfoo LLM testing?

Promptfoo is an open-source command-line tool and library for evaluating and red-teaming language model applications. It was built for developers who wanted test-driven development for prompts, rather than trial and error. You give it three things: your prompt templates, the models you want to test, and test cases with assertions. It runs every combination and reports the results.

The whole evaluation lives in a single YAML configuration file, usually called promptfooconfig.yaml, which sits in version control next to the code it tests. Because the configuration is declarative, a teammate can read it and understand exactly what is being tested, without running a notebook or reading application code. The tool runs locally by default, so your configuration, results and cache stay on your own machine, and provider calls go directly to the provider you configured.

How a Promptfoo eval works

An eval starts with a prompt template, which is the text sent to the model, with placeholders for variables. Each test case supplies values for those variables, plus the expected output or the assertion that will judge it. Promptfoo runs each prompt against each test case for each configured model, then scores the outputs.

The results appear as a matrix view, where each row is a test case and each column is a prompt or model combination. A web viewer lets you inspect individual outputs, which is useful when a test fails: you can read the exact answer the model gave and decide whether the test or the prompt needs to change. That inspection step matters, because a failing assertion does not always mean the model was wrong.

Assertions: defining what good looks like

Assertions are the heart of Promptfoo LLM testing. An assertion is a rule that an output must satisfy, and Promptfoo provides many types. Simple ones check whether the output contains a phrase, matches a regular expression, or follows a JSON schema. These are fast, deterministic, and easy to explain when they fail.

More flexible assertions use a language model as a judge, scoring the output against a rubric or checking factuality. These handle cases where the correct answer cannot be written as a fixed string, such as a summary that could be phrased in many ways. The trade-off is that a judge can be wrong, or can share the blind spots of the model it is judging, so judge-based assertions need their own spot checks.

Choosing assertions is a design decision, not a default. A test with only contains checks will pass answers that are technically correct but unhelpful, while a test with only judge-based checks will be harder to debug when it fails. A good suite mixes both: deterministic checks for format and facts, and judge-based checks for qualities such as relevance and completeness. For more on choosing metrics wisely, see LLM evaluation metrics, which explains what each metric measures and where it fails.

Comparing prompts and models

Promptfoo’s matrix makes comparison concrete. Change one line in a prompt, run the eval again, and the matrix shows which test cases improved and which got worse. That turns prompt engineering from a matter of taste into a matter of evidence, because the same cases are used before and after the change. Best for: teams iterating on prompts, comparing model providers, and deciding whether a cheaper model is good enough for a task.

The same approach works for model selection. Run the same cases against two or three models and compare the pass rates, the failure modes, and the cost of each run. A model that scores slightly lower but costs far less may be the right choice for a low-stakes task, while a high-stakes task may justify the stronger model. The eval gives you the numbers to make that call openly.

Regression testing in continuous integration

Because Promptfoo runs from the command line and returns an exit code, it fits naturally into continuous integration. A failing eval can block a deployment, just as a failing unit test blocks a code release. That is the point: prompt changes, model changes and data changes are all changes, and they should all be tested before they ship. Best for: teams that already use continuous integration and want language model changes held to the same standard as code changes.

Our guide to prompt regression testing covers the same idea in more depth, including how to build a test set that catches quality drops before users notice them. The key habit is to add a test case every time a failure is found in production, so the same failure cannot return unnoticed.

Red teaming with Promptfoo

Promptfoo also includes red teaming, which generates adversarial tests designed to find security and safety weaknesses. You choose the risks to probe, such as prompt injection, jailbreaks, personal data leakage, or excessive agency, and Promptfoo generates attack inputs aligned with recognised taxonomies such as the OWASP LLM Top 10. It then runs those attacks and reports which ones succeeded.

The results come as vulnerability and risk reports, showing which categories of attack succeeded and how often. Those reports are a starting point, not a verdict: a successful attack in testing shows where the system needs stronger guardrails, a tighter tool scope, or a human check before a sensitive action. See AI red teaming frameworks for what these frameworks cover and where they stop.

Comparing Promptfoo with other evaluation tools

Tool or approach Main focus Main strength Main limitation
Promptfoo Pre-deployment evals and red teaming from a config file Fast, local, and fits in continuous integration Less focused on live production tracing
DeepEval Python metrics library for LLM outputs Rich set of ready-made metrics Needs Python code for each test
Giskard Scanning for bias, security and performance issues Finds problems you did not think to test for Needs review to sort real risks from noise
Opik Tracing, evaluation and monitoring in one platform Connects development evals to production data More setup than a command-line tool
Manual review A person reads outputs and judges quality Best judgement on subtle cases Slow and hard to repeat

The tools overlap, and many teams use more than one. Promptfoo is the strongest choice when the goal is a fast, repeatable gate before deployment, especially for prompt and model comparison. Tools built around tracing are stronger when the question is what happened in production, and metric libraries are stronger when a team wants fine-grained control over scoring in Python. For help deciding when human judgement should stay in the loop, see human versus automated AI evaluation.

Hands typing on a laptop beside a monitor showing a grid of coloured result squares
The matrix view is the point of Promptfoo: one glance shows which prompt and model combinations pass, and which test cases fail.

When Promptfoo is the right choice

Promptfoo suits teams that already think in terms of tests and pipelines. If your team writes unit tests for code, Promptfoo gives you the same habit for prompts: a small, fast suite that runs on every change, plus a larger suite that runs before release. It also suits small teams, because the setup is a single configuration file rather than a platform to operate.

It is less suited to teams that need deep production observability, such as tracing every step of a multi-agent workflow in live traffic. Promptfoo can evaluate and red-team, but it is not primarily a monitoring platform. Teams with that need usually pair a pre-deployment tool like Promptfoo with a tracing platform for production.

It is also worth knowing that Promptfoo was acquired by OpenAI in March 2026, while remaining open source under the MIT licence. Teams that care about the project’s direction should watch its releases, but the practical point for most users is unchanged: the tool runs locally, the configuration is yours, and the evals are portable.

Promptfoo LLM testing checklist

  • Write the prompt template with clear placeholders for each variable.
  • Collect test cases from real user inputs, including awkward and adversarial ones.
  • Define assertions before running the eval, not after seeing the outputs.
  • Mix deterministic checks with judge-based checks for open-ended quality.
  • Run the same cases against each candidate prompt and model.
  • Add a test case for every failure found in production.
  • Run the eval in continuous integration and block deploys on failure.
  • Run red teaming before release, and fix the successful attacks first.
  • Spot-check judge-based scores by reading a sample of outputs yourself.
  • Review and prune the suite regularly, so it stays fast and relevant.

Frequently asked questions

What is Promptfoo LLM testing?

It is the practice of evaluating language model applications with Promptfoo, an open-source tool that runs prompts against test cases with defined assertions. It scores each output, compares prompts and models side by side, and can run in continuous integration.

Do I need to write code to use Promptfoo?

Not for a basic eval. You define prompts, models and test cases in a YAML configuration file, and run the eval from the command line. Code is useful for custom assertions and integrations, but the core workflow is declarative.

Is Promptfoo free and open source?

Yes. Promptfoo is open source under the MIT licence, and the core eval runner runs locally on your machine. It was acquired by OpenAI in March 2026, and the project has stated that it will remain MIT-licensed open source.

What is the difference between Promptfoo and a benchmark?

A benchmark runs a fixed public test set and produces a comparable score. Promptfoo runs your own test cases, built around your prompts and your users, and reports pass and fail results for each case. Benchmarks compare models in general; Promptfoo tests your application in particular.

Can Promptfoo test retrieval-augmented generation?

Yes. You can include retrieved context as a variable in your test cases and assert on whether the answer stays grounded in that context. That makes it useful for RAG systems, where the failure may be in the retrieval, the generation, or the way the two are combined.

Does Promptfoo replace human review?

No. It catches regressions and security weaknesses at a scale no person can match, but it cannot judge subtle quality, tone, or context the way a person can. Read a sample of outputs yourself, especially for judge-based assertions, and treat the eval as a gate, not a verdict.

Latest articles

Scroll to Top