Skip to main content

Caching

promptfoo caches the results of API calls to LLM providers. This helps save time and cost.

Command line

If you're using the command line, you may call promptfoo eval with --no-cache to disable the cache, or set cache: false in your config file.

Tests

If you're integrating with jest, mocha, or any other external framework, you'll probably want to set the following for CI:

PROMPTFOO_CACHE_TYPE=disk
PROMPTFOO_CACHE_PATH=...

Configuration

The cache is configurable through environment variables:

Environment VariableDescriptionDefault Value
PROMPTFOO_CACHE_ENABLEDEnable or disable the cachetrue
PROMPTFOO_CACHE_TYPEdisk or memorymemory if NODE_ENV is test, otherwise disk
PROMPTFOO_CACHE_MAX_FILE_COUNTMaximum number of files in the cache10,000
PROMPTFOO_CACHE_PATHPath to the cache directory~/.promptfoo/cache
PROMPTFOO_CACHE_TTLTime to live for cache entries in seconds14 days
PROMPTFOO_CACHE_MAX_SIZEMaximum size of the cache in bytes10 MB