examples/config-tests-per-provider/README.md
This example demonstrates how to run different tests against different providers in a single evaluation using the providers filter on test cases.
defaultTest to set provider filters globallynpx promptfoo@latest init --example config-tests-per-provider
npx promptfoo@latest eval
Without filtering, promptfoo creates a cross-product of all tests × providers. If you have 2 tests and 2 providers, you get 4 test cases. This example shows how to run specific tests only against specific providers.
Each test case can specify which providers it should run against:
tests:
- vars:
question: 'Quick math question'
providers:
- fast-model # Only runs on fast-model
assert:
- type: latency
threshold: 2000
- vars:
question: 'Complex reasoning'
providers:
- smart-model # Only runs on smart-model
The providers filter supports multiple matching patterns:
| Pattern | Example | Matches |
|---|---|---|
| Label | fast-model | Provider with label: fast-model |
| Exact ID | openai:gpt-4 | Provider with that exact ID |
| Wildcard | openai:* | All providers starting with openai: |
| Prefix | openai | All providers starting with openai: |
Use defaultTest.providers to apply filters to all tests:
defaultTest:
providers:
- openai:* # All tests default to OpenAI only
tests:
- vars:
question: 'Question 1'
- vars:
question: 'Question 2'
providers:
- anthropic:* # Override for this test only
Instead of 6 test cases (3 tests × 2 providers), this example runs exactly 3 test cases: