Intermediate 12 minDaily plan

Promptfoo and Ollama: testing your prompts in local

An open laptop casts green light across a dark desk.

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.

By Mohamed Meguedmi·Update 2026-11-27·Tested on Windows, macOS, and Linux

#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

The complete kit for building your own AI assistant.

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.
Terminal
# Vérifier qu'Ollama répond et lister les modèles disponibles
curl http://localhost:11434/api/tags
ollama list

# Télécharger un modèle de travail (tag d'exemple : remplacez-le par le vôtre)
ollama pull qwen3.5:9b

#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.

i
Check the official page before copying
The identifiers and options mentioned here come from the Promptfoo documentation as of October 30, 2026. Promptfoo evolves quickly: if you get an error message about an option, the providers/ollama page on promptfoo.dev is the authoritative reference.

#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.

  1. 01
    Create a working folder
    A 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.
  2. 02
    Write the prompt with variables
    Variables go inside double curly braces, for example {{ticket}}. Each test case will supply its own value.
  3. 03
    Declare the Ollama provider
    Specify ollama:chat followed by the exact model tag, and set temperature to 0 to reduce variability between two runs.
  4. 04
    Add the test cases
    Each test pairs variables (the fictional input) with a list of assertions (what must be true for the test to pass).
  5. 05
    Run the evaluation
    promptfoo eval runs every prompt × provider × test combination, then promptfoo view opens the local results viewer.
Terminal
mkdir tests-prompts && cd tests-prompts

# Générer un squelette de configuration (optionnel)
npx promptfoo@latest init
promptfooconfig.yaml
description: 'Classement de tickets fictifs'

prompts:
  - |
    Tu classes des tickets de support.
    Réponds uniquement par un objet JSON de la forme
    {"categorie": "facturation|technique|autre", "urgence": "basse|haute"}
    sans texte autour.
    Ticket : {{ticket}}

providers:
  - id: ollama:chat:qwen3.5:9b
    config:
      temperature: 0

tests:
  - description: 'Double prélèvement (fictif)'
    vars:
      ticket: 'Bonjour, mon abonnement a été débité deux fois ce mois-ci.'
    assert:
      - type: is-json
      - type: javascript
        value: JSON.parse(output).categorie === 'facturation'

  - description: 'Application qui plante (fictif)'
    vars:
      ticket: 'Depuis la mise à jour, l’application se ferme dès que j’ouvre un document.'
    assert:
      - type: is-json
      - type: javascript
        value: JSON.parse(output).categorie === 'technique'

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.
promptfooconfig.yaml (excerpt)
  - description: 'Demande hors sujet (fictif)'
    vars:
      ticket: 'Quel temps fera-t-il demain à Lyon ?'
    assert:
      - type: is-json
        value:
          type: object
          required: ['categorie', 'urgence']
          properties:
            categorie:
              enum: ['facturation', 'technique', 'autre']
            urgence:
              enum: ['basse', 'haute']
      - type: javascript
        value: JSON.parse(output).categorie === 'autre'
      - type: not-icontains
        value: 'en tant qu’IA'

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.

→
Factor out with defaultTest
Assertions shared by all cases (is-json with the schema, for example) can be placed once under defaultTest.assert. Each test then keeps only its specific checks, which makes the file easier to read.

#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.

promptfooconfig.yaml (excerpt)
defaultTest:
  options:
    provider:
      text:
        id: ollama:chat:gemma4:12b
        config:
          temperature: 0
      embedding:
        id: ollama:embeddings:nomic-embed-text

tests:
  - description: 'Ticket agressif (fictif)'
    vars:
      ticket: 'C’est la troisième fois que je vous écris, réglez ce bug de facturation immédiatement.'
    assert:
      - type: javascript
        value: JSON.parse(output).urgence === 'haute'
      - type: llm-rubric
        value: 'La réponse est uniquement un objet JSON, sans excuse ni commentaire adressé au client.'

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.

!
Model grading isn't ground truth
An llm-rubric verdict is itself a model output: it can vary from one run to the next, get an edge case wrong, or be swayed by how the rubric is worded. Reserve it for criteria that can't be coded, review its justifications, and never present its pass rate as an objective measure of quality.
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

Terminal
# Exécuter la batterie de tests
npx promptfoo@latest eval

# Ignorer le cache (utile après un changement de modèle côté Ollama)
npx promptfoo@latest eval --no-cache

# Répéter chaque cas pour observer la variabilité
npx promptfoo@latest eval --repeat 3

# Exporter les résultats pour les archiver
npx promptfoo@latest eval -o resultats.json

# Ouvrir l'interface locale de consultation
npx promptfoo@latest view

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.
!
Fictional data, truly
Even if everything stays local, Promptfoo's configuration files, JSON export, and results database keep the inputs and outputs. Don't put real personal data in them, especially if the folder is version-controlled or shared.

#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.
Terminal
# Pointer Promptfoo vers un Ollama précis le temps d'une exécution
OLLAMA_BASE_URL=http://127.0.0.1:11434 npx promptfoo@latest eval

#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.

Did this guide help you?

Feedback, an error, or a clarification? Let us know—it improves the guide for everyone.