Promptfoo and Ollama: testing your prompts in local

Promptfoo and Ollama make a simple pair for checking that a prompt still does what you expect when you change the model, the quantization, or the wording. This guide shows how to configure Promptfoo with Ollama, a few explicit assertions on made-up inputs, and the difference between a deterministic test and a judgment delegated to a model. It is based on the official documentation consulted on 30/10/2026; no model output or score is reproduced here, because results depend on your machine and the model you choose.
#Why test your prompts with Promptfoo and Ollama
A prompt that works today has no guarantee of working tomorrow. Switching from a 9B model to a 12B, changing quantization (Q4_K_M to Q8_0, for example), updating Ollama, or rewording an instruction is all it takes for the output format to change, a category to be misassigned, or sensitive information to reappear. Without tests, you find out in production, or never.
Promptfoo is an open-source command-line tool that runs a list of prompts against one or more model providers, across a set of test cases, and checks each response with assertions. The principle is the same as regression testing in software development: you freeze representative inputs, describe what's acceptable, and rerun the suite after every change. With Ollama as the provider, everything runs on your machine: prompts and test data never leave your computer, and there's no per-call bill.
This guide doesn't compare models and doesn't publish any ranking. It provides a method and a starter configuration for you to adapt to your own use case. To understand what public benchmarks are worth, and why they don't replace your own tests, see our guide on LLM leaderboards, linked at the end of the page.
#Prerequisites
Benefit from our experience and a guided path to build your local assistant and use your AI every day.
- Lifetime online access
- PDF + files
- Refunded within 30 days
- Ollama installed and started
- By default, the daemon listens on http://localhost:11434. Use ollama list to check that at least one model is downloaded.
- Node.js
- Promptfoo is distributed via npm. The npx command lets you run it without a global install; installing via npm install -g promptfoo or Homebrew is also documented.
- A working model
- A 7 to 14B model in Q4_K_M is enough to get started: expect about 5 GB of VRAM for a 7B and 9 GB for a 14B. A 12 GB RTX 3060 or a 24 GB Mac M4 Pro will do.
- A grader model (optional)
- For model-graded assertions, a second local model, ideally more capable than the one under test. On a 12 GB card, the two won't necessarily fit in memory at the same time: Ollama will load them in turn.
- Fictional inputs
- Made-up but realistic examples, with no personal data or real customers. You can version them alongside the rest of the project.
#Declaring Ollama as a provider in Promptfoo
In Promptfoo, a "provider" is the model you query. The official page for Ollama (promptfoo.dev/docs/providers/ollama, consulted on 30/10/2026) documents three families of identifiers: ollama:chat:<model> for the chat API, ollama:completion:<model> for raw generation, and ollama:embeddings:<model> for the vectors used by some similarity assertions. The model name is the exact tag shown by ollama list.
- ollama:chat:qwen3.5:9b
- The most common option: the prompt is sent as a message, and Ollama applies the model's chat template.
- ollama:completion:qwen3.5:9b
- Useful for testing a raw prompt, without chat formatting.
- ollama:embeddings:nomic-embed-text
- Embeddings provider, used by the similar assertion if you configure it locally.
- OLLAMA_BASE_URL
- Environment variable Promptfoo reads to reach an Ollama server somewhere other than localhost:11434 (another machine on the network, a container).
Generation parameters go in a config block under the provider. The documentation lists, among others, temperature, top_p, top_k, num_predict, and seed. For regression tests, setting the temperature to 0 reduces variability without eliminating it entirely: the order of GPU computations or a version change can still produce differences.
#A first configuration, step by step
The example chosen here is deliberately modest: classifying fictional support tickets into three categories and returning a JSON object. This kind of task lends itself well to testing, because the expected output is structured and verifiable.
- 01Create a working folderA dedicated folder will hold the promptfooconfig.yaml file and, later on, your test sets. Promptfoo's init command can generate a skeleton, or you can write the file by hand.
- 02Write the prompt with variablesVariables go inside double curly braces, for example {{ticket}}. Each test case will supply its own value.
- 03Declare the Ollama providerSpecify ollama:chat followed by the exact model tag, and set temperature to 0 to reduce variability between two runs.
- 04Add the test casesEach test pairs variables (the fictional input) with a list of assertions (what must be true for the test to pass).
- 05Run the evaluationpromptfoo eval runs every prompt × provider × test combination, then promptfoo view opens the local results viewer.
These two tickets are made up for the example. In a real project, build at least about twenty cases, including ambiguous situations and errors you've already run into: those are the ones most likely to regress.
#Deterministic assertions: what you can check without a model
A deterministic assertion is a rule checked by code: for the same output, it always returns the same verdict. This is the category to favor, since it's fast, computationally free, and unambiguous. Promptfoo offers several; here are the most useful ones for local use.
- contains / icontains
- The output contains a string, case-sensitive or case-insensitive.
- not-contains / not-icontains
- The output doesn't contain a string: handy for banning a phrase, a competitor's product name, or data that shouldn't leak.
- equals / starts-with
- Strict equality or a required prefix, suited to very short responses (a single word, a code).
- regex
- The output matches a regular expression: date format, reference number, absence of tags.
- is-json / contains-json
- The output is valid JSON, or contains some. is-json also accepts a JSON schema as its value to check the structure.
- javascript / python
- A custom expression or script receives the output and returns true or false (or a score). It's the most flexible tool for checking a specific field.
- latency
- The response arrives under a threshold in milliseconds. On a local machine, this number depends on the current load: use it with a wide margin.
The JSON schema above does most of the work: it rejects an invented category, a missing field, or an urgency value outside the list. The javascript assertion then checks the expected content for this specific case. If the model wraps its JSON in text or code fences, is-json fails: that's intentional, since the prompt forbids it, but you may prefer contains-json if your application can extract JSON from a wordier response.
#Model grading: evaluating with Ollama locally
Some qualities can't be reduced to a rule: Is a summary faithful? Is a tone polite? Does a response properly decline an out-of-scope request? For these cases, Promptfoo offers so-called "model-graded" assertions, the best known of which is llm-rubric: you describe the expected criterion in natural language, and a grader model returns a verdict along with a rationale.
By default, these assertions rely on a remote provider. To stay fully local, Promptfoo's Ollama documentation shows how to replace the grader with an Ollama model via defaultTest.options.provider, using a text model for rubrics and, if needed, an embedding model for the similar assertion.
The tags gemma4:12b and nomic-embed-text are examples: use models that are actually present on your machine. Ideally, the grader model should be different from the one being tested, and at least as capable; a model grading itself tends to be lenient about its own flaws.
- Deterministic test
- Coded rule, reproducible verdict, negligible cost. Ideal for format, fields, banned words, and lengths.
- Model grading
- Criterion expressed in natural language, probabilistic verdict, cost of an extra call to the grader model. Useful for faithfulness, tone, and relevance.
- Rule of thumb
- Start with deterministic checks; add a rubric only when no rule catches the flaw you want to detect.
#Running Promptfoo with Ollama and reading the results
At the end of a run, Promptfoo displays a table in the terminal: one row per test case, one column per prompt × provider combination, and for each cell a pass or fail status along with the output produced. The summary shows the number of passes, failures, and errors. The interface opened by promptfoo view presents the same data in a browsable form, with details for each assertion and, for llm-rubric, the grader model's reasoning.
Be clear about the difference between a failure and an error. A failure means the model responded but the response doesn't satisfy an assertion: that's the information you're after. An error means the call didn't complete (missing model, unreachable server, timeout): in that case, there's nothing to conclude about the prompt's quality.
To compare two variants, add a second prompt or a second provider to the configuration: each test will run on every combination, and the table will show them side by side. Keep in mind that a difference of a few cases on a small test set proves nothing; rerun with --repeat before drawing any conclusion, and look at the outputs themselves rather than just the percentage.
In continuous integration, promptfoo eval returns a non-zero exit code when tests fail, which lets you block a change. Check the documentation for the exact behavior of your version before relying on it, and plan for your CI runner to be able to reach an Ollama server with the right models.
#Limits and pitfalls to know
- Residual non-determinism
- Even at temperature 0, an Ollama update, a different GPU, or a different quantization can change the output. A test that passes once may fail the next time: that's a signal to investigate, not necessarily a regression.
- Response cache
- Promptfoo caches provider responses. If you replace a model under the same tag (ollama pull d of a new version), use --no-cache so you don't evaluate stale responses.
- Reasoning models
- Some models produce a thinking phase before the answer. Depending on how it's returned, it can make is-json or equals fail. Test a single case first and adjust the assertions or the model configuration.
- Limited coverage
- Tests only check what you've written. A set of twenty fictional tickets guarantees nothing about the thousandth real ticket: expand it every time you hit a problem.
- Fragile rubrics
- A vague rubric ("the answer is good") produces verdicts that aren't very actionable. Write one observable criterion per assertion.
- Memory and runtime
- Each case triggers at least one model call, two with a grader. On a 12 GB card, switching between two 9–12B models forces reloads: total runtime depends heavily on your hardware and isn't estimated here.
#Troubleshooting
- Connection refused
- Check that Ollama is running (curl http://localhost:11434/api/tags). If localhost resolves to IPv6 on your system, try OLLAMA_BASE_URL=http://127.0.0.1:11434.
- Model not found
- The name after ollama:chat: must exactly match the tag shown by ollama list, including the suffix (for example :9b or :12b).
- Server on another machine
- Set OLLAMA_BASE_URL to the server's address and make sure Ollama is listening there on a reachable interface, not just locally.
- Timeouts
- The first call includes loading the model into memory. Run a ollama run pr beforehand, lower the evaluation's concurrency, or pick a lighter model.
- is-json fails even though the output looks correct
- Look at the raw output in promptfoo view: a Markdown code block or an introductory sentence is enough to invalidate the JSON.
#Go further
Prompt tests complement public benchmarks without replacing them: a leaderboard measures a model on generic tasks, while your Promptfoo tests measure your prompt on your task. To read MMLU, LMArena, or SWE-bench correctly and understand their biases, see our guide "LLM Benchmarks: Understanding Leaderboards" (/guide/benchmarks-llm-comprendre-leaderboards).
- LLM benchmarks: understanding leaderboards
- What major benchmarks measure, contamination and saturation: /guide/benchmarks-llm-comprendre-leaderboards
- Installing Ollama on Linux
- Setting up the daemon and your first models: /guide/installer-ollama-linux
- The Ollama REST API with Python
- Calling Ollama from your own scripts, useful for custom python assertions: /guide/ollama-api-rest-integration-python
Primary sources: Promptfoo documentation, Ollama provider (https://www.promptfoo.dev/docs/providers/ollama/), as of October 30, 2026. The configuration in this guide was not run while writing it: validate it on your own setup before relying on its results.
Feedback, an error, or a clarification? Let us know—it improves the guide for everyone.