site/docs/configuration/caching.md
promptfoo caches the results of API calls to LLM providers to help save time and cost.
The cache is managed by cache-manager with keyv and keyv-file for disk-based storage. By default, promptfoo uses disk-based storage (~/.promptfoo/cache).
Cache entries are stored using provider-specific composite keys that include:
Cache key formats are implementation details and may change between versions. Sensitive request payloads and headers are hashed where possible instead of being embedded directly in cache keys.
// Provider-specific scope plus a digest of request material
const providerCacheKey = `openai:gpt-5:<request-digest>`;
// HTTP fetch cache entries include URL, method, headers, options, and body identity
const fetchCacheKey = `fetch:v3:<request-digest>`;
evaluateOptions.repeat or --repeat is greater than 1, each repeat index uses a separate cache namespace. Re-running the same eval can reuse those per-repeat cached responses, while preserving distinct outputs between repeat 0, repeat 1, etc.NODE_ENV=testIf you're using the command line, call promptfoo eval with --no-cache to disable the cache, or set { evaluateOptions: { cache: false }} in your config file.
Use --no-cache with --repeat when you want every run to make fresh LLM calls instead of replaying each repeat index from cache.
Use promptfoo cache clear command to clear the cache.
Set EvaluateOptions.cache to false to disable cache:
promptfoo.evaluate(testSuite, {
cache: false,
});
If you're integrating with jest or vitest, mocha, or any other external framework, you'll probably want to set the following for CI:
PROMPTFOO_CACHE_TYPE=disk
PROMPTFOO_CACHE_PATH=...
The cache is configurable through environment variables:
| Environment Variable | Description | Default Value |
|---|---|---|
| PROMPTFOO_CACHE_ENABLED | Enable or disable the cache | true |
| PROMPTFOO_CACHE_TYPE | disk or memory | memory if NODE_ENV is test, otherwise disk |
| PROMPTFOO_CACHE_PATH | Path to the cache directory | ~/.promptfoo/cache |
| PROMPTFOO_CACHE_TTL | Time to live for cache entries in seconds | 14 days |
PROMPTFOO_RETRY_5XX=trueYou can clear the cache in several ways:
promptfoo cache clear
const promptfoo = require('promptfoo');
await promptfoo.cache.clearCache();
rm -rf ~/.promptfoo/cache
You can force a cache miss in two ways:
--no-cache to the CLI:promptfoo eval --no-cache
const result = await fetchWithCache(url, options, timeout, 'json', true); // Last param forces cache miss