How promptfoo runs in a CircleCI pipeline
A team whose LLM application changes need automated checks before merge can run promptfoo from a job in .circleci/config.yml. The documented approach installs promptfoo in the job, runs the evaluations, and reuses results between runs through caching so unchanged test cases do not call the model again. Because promptfoo is licensed under the MIT license, the tool itself carries no license fee, and the cost to plan for is model API usage and CI minutes.
promptfoo runs locally on the CI runner and calls the model providers directly. Nothing is sent to a promptfoo-hosted service during an eval, so the provider keys must be present in the job environment and the runner must have outbound network access to each provider endpoint. The current npm release requires Node.js 22.22.0 or newer, so the job image or the node version it installs must meet that minimum before the first run. Confirm the Node version in your image with the release notes on the CircleCI integration guide and pin the promptfoo version you test against.
Before you write the job, decide which providers the eval calls, where their keys will live, and whether the cache directory will persist between builds. Those three choices determine the cost of each run, the blast radius if a key leaks, and whether a rerun on an unchanged prompt is cheap. Ask your platform team which CircleCI plan and runner type your organization uses, since that controls how caches and secrets are scoped across projects.
What you need before the first CircleCI run
Most first CircleCI runs fail on something outside the config file: a Node.js version below the minimum, a missing provider key, or a runner that cannot reach the model APIs. The cards below cover the project, runtime, credentials, repository contents and network path, in the order you should confirm them.
CircleCI project and plan
Confirm that the repository is connected to a CircleCI project in the organization that will own the pipeline, and that your plan includes the execution resources you expect to use. Decide whether jobs run on CircleCI-hosted machines or on a self-hosted runner, because that choice determines who maintains the Node.js install and the outbound network path. Check how many concurrent jobs your plan allows before setting up a matrix of model or prompt variants.
promptfoo CircleCI guideNode.js runtime for the current release
The current promptfoo release, 0.124.1, requires Node.js 22.22.0 or newer. Pick a CircleCI Node image tag that resolves to that version or later, and pin it in .circleci/config.yml rather than relying on a floating tag. Confirm the exact tag you use by running node --version in a test job, because image tags change over time. If you run a self-hosted runner, you must install Node.js on that machine yourself and keep it current.
Provider accounts and spend limits
Create a dedicated API key for each model provider the pipeline calls, separate from keys used by people or production services. Ask each provider for the spending limit and rate limit options available on that account, and set a monthly cap before the first run. Note which key is used by the system under test and which is used by the grader model, because both generate charges. Record who owns each account so that key rotation has a named owner.
Context or project variables for keys
Store provider keys in a CircleCI context restricted to the branches and projects that should use them, or in project environment variables if only one project needs them. Keep keys out of config.yml, out of promptfoo config files and out of logs. Decide who can view or change the context, since anyone with access to a context can read values used by jobs in that context. Plan a rotation procedure that updates the context and then reruns the affected pipeline.
Repository with promptfoo config and datasets
The repository needs a promptfoo configuration file, the prompts and providers it references, and the eval datasets (CSV or JSON test cases). Check that test data contains no real customer records or secrets, because eval outputs and reports may echo inputs. Commit a lockfile so the promptfoo version installed in CI matches the one you tested locally. Confirm the cache directory you plan to persist between builds is excluded from source control.
Network egress from the runner
The job must reach each model provider's API endpoint over HTTPS, and it must reach the npm registry to install promptfoo. Hosted CircleCI runners need no inbound configuration, but a self-hosted runner in a restricted network needs outbound rules to every provider endpoint and to npm. If your organization routes traffic through a proxy or a self-hosted AI gateway, confirm the proxy address and any certificate trust chain before the first run. Test egress with a short job that makes one API call and fails clearly if the connection is blocked.
Configure .circleci/config.yml step by step
This sequence turns a CircleCI pipeline into a repeatable promptfoo eval job that caches responses between builds, keeps provider keys out of the repository and logs, and keeps eval output for review. Each step ends with a check you can run before moving on.
Create the job with a Node.js executor
Define a job in .circleci/config.yml that runs on a Node.js image, since promptfoo is distributed through npm and the current npm release requires Node.js 22.22.0 or newer. Confirm the image tag you choose meets that minimum, and check the promptfoo releases page for later requirements before you pin the version. The step is done when a pipeline run starts the job and
node --versionprints a version at or above the minimum in the job log.Restore the cache keyed on config and prompts
Add a restore_cache step that points at promptfoo's local cache directory and uses a key built from your promptfoo config and prompt files, so a change to either produces a new cache. Ask your team to confirm the cache path in the promptfoo CircleCI guide for the version you run, because the location is set by the tool and not by your pipeline. The step is done when a second build of an unchanged branch logs a cache hit for that key.
Install promptfoo at a pinned version
Add a run step that installs promptfoo with npm at a fixed version rather than the latest release, so a new release does not change grading behavior between builds without review. Record the version in your repository and update it deliberately. The step is done when
npx promptfoo --versionprints the pinned version in the job log.Inject provider keys from a context
Store each model provider key in a CircleCI context or as a project environment variable, then attach that context to the workflow so the job receives it at runtime. Keys should never be written into config.yml or the promptfoo config. Use a context when several projects share the same key and restrict who can edit it. The step is done when the job reads the variable (for example, by checking that it is non-empty with a silent test command) and the value itself does not appear anywhere in the log.
Run the eval command
Add a run step that executes
promptfoo evalagainst your config, with an output file written to a known path so later steps can find it. Decide whether the step should fail the build on failed assertions or only report them, and check the exit code behavior for your promptfoo version. To verify the gate, temporarily break a prompt on a test branch and confirm the job exits with the non-zero code you expect.Save the cache after the run
Add a save_cache step after the eval so the responses generated in this build are stored under the key from the restore step. Save even when the eval fails, if your team wants the cache to speed up the next attempt, and confirm that your cache policy matches your retention and data rules. The step is done when the next build on the same config and prompts restores this cache and makes fewer provider calls than the previous run.
Store output and check the job log
Add a store_artifacts step that uploads the eval output file so reviewers can open it from the CircleCI job page, and review what the file contains before you grant broad access, since it can include prompts and model responses. Then search the full job log for your provider key values and key prefixes to confirm nothing leaked. The step is done when the artifact appears on the job's Artifacts tab and the log search returns no key matches.
How caching LLM responses between builds cuts repeat API calls
The documented CircleCI guide for promptfoo configures caching so that results from one run are reused in later runs. For test cases whose prompt, provider and inputs have not changed, the build can skip the provider call and reuse the stored response, which is where repeat API spend in CI comes from. The saving depends on how often your suite is unchanged between builds, so the first thing to measure is the hit rate on a typical feature branch, not the theoretical maximum.
Cache reuse is only safe if the key changes when something that affects the output changes. Confirm in the current promptfoo docs which inputs feed the cache key, and check that the prompt text, provider configuration and dataset contents are all covered. Then look at what is not covered in your setup, such as an environment variable that changes model behavior or a grader model that was swapped. A stale cache hides a real regression: the old response passes while the new prompt would have failed. Where the cache key does not capture a change, the build reports green for code that was never re-tested, so schedule periodic full runs without the cache on the main branch.
Confirm hits in the build log before relying on the cache for cost control. Look for the run summary that reports how many test cases were served from cache versus sent to the provider, and compare the provider usage shown by your model platform for the same build. Verify the cache directory path and whether CircleCI's save_cache and restore_cache steps persist it between pipelines on your branch and project setup. Treat the cache location, key behavior and any setting names as items to check against the current promptfoo documentation, since they can change between releases.
Where to keep provider keys: contexts or project variables
A CircleCI context is an organization-level group of environment variables that you attach to specific workflows. It suits provider keys that several projects use, such as one OpenAI or Anthropic key shared by a set of LLM applications. Access is controlled through CircleCI organization settings, where you can restrict a context to named groups, so only members of those groups can view or edit its values. CircleCI injects the variables into the job environment only for jobs that reference the context, which keeps the key away from unrelated pipelines.
- Who can read: Values are write-only in the CircleCI interface, so members can add or replace a value but cannot view it afterward. Confirm this behavior for your plan.
- Who can change: Restricted contexts limit which users or groups may use them in a workflow, and organization admins manage membership.
- How it reaches the job: The variables are exported as environment variables when a job that names the context starts.
- What appears in logs: CircleCI masks context values in job output, but masking depends on exact string matches, so an echoed value that is transformed, split or base64 encoded can still appear.
Before you adopt contexts, confirm with CircleCI how restriction groups and value masking work on your plan and in your organization settings.
A project environment variable belongs to one CircleCI project, which is typically one repository. It suits a single application team that runs promptfoo evals against its own prompts and has no need to share the key elsewhere. Anyone with access to the project settings can manage its variables, so the scope of the key follows the scope of the project. Keeping the key at project level also means a leaked key affects only the pipelines of that repository.
- Who can read: Users with project settings access can add or replace values. Like contexts, values are not displayed again after saving.
- Who can change: Project admins and anyone granted project settings rights can edit the variable, which is often a wider group than a security team expects.
- How it reaches the job: Every job in the project receives the variable, including jobs triggered by branches or forks you may not fully trust. Review how your project handles fork pull requests and untrusted branches before exposing a provider key.
- What appears in logs: Masking applies to the stored value, but a step that runs
echoon a derived value or prints the full environment will expose it. Avoid debugging commands such asenvin eval jobs.
When several repositories need the same key, moving it to a context usually gives you one rotation point and one place to audit.
For organizations that rotate keys centrally, the job can fetch the provider key from a secrets manager when it runs, instead of storing it in CircleCI at all. The CircleCI project then holds only the credentials needed to reach the secrets manager, typically a short-lived identity or a narrowly scoped token. Rotation happens once in the secrets manager, and the next job receives the new value without anyone editing CircleCI settings. Your security team keeps its audit trail in the system that already governs other production secrets.
- Who can read: Access is governed by the secrets manager's policies, which can be separate from CircleCI project and context roles.
- Who can change: Only identities allowed by the secrets manager policy can create or rotate the key, which narrows change authority.
- How it reaches the job: A step authenticates to the secrets manager and exports the key into the job environment for the duration of the run. Confirm how your chosen manager issues and revokes that credential.
- What appears in logs: The fetch step must avoid printing the response. Write the value to the environment or a file with restricted permissions, and never echo it in a debug step.
This approach adds a dependency on the secrets manager's availability and a setup cost for the job identity. Ask your platform team which manager and identity model they already operate before you design the flow.
Regardless of where the key is stored, the most common leak is a job step that prints it. Promptfoo itself reads provider keys from environment variables and does not need them written to config files, so the safest pattern keeps the key out of promptfooconfig.yaml and out of any file committed to the repository. CircleCI masking is a safeguard, not a control you can rely on alone, because it matches the exact string it has stored.
- Config files: Reference variables from the environment in your promptfoo configuration instead of pasting keys into YAML.
- Debug steps: Remove
env,printenvand verbose shell tracing (set -x) from jobs that hold provider keys. - Artifacts: Check that cached responses, JSON outputs and HTML reports do not include request headers or keys before you store them as artifacts.
- Fork and branch builds: Confirm whether forked pull requests receive project variables and contexts in your organization settings.
- Rotation test: Rotate a test key and confirm that the next job uses the new value and the old one stops working.
Ask your security team to review a sample job log and a sample artifact before the first production run.
Mapping provider keys and pipeline variables to promptfoo
This table maps each provider credential to the CircleCI context or project variable that holds it, the promptfoo config reference that reads it, the jobs or branches allowed to use it, and the owner who rotates it. Use it as a template for access review, and confirm exact environment variable names against the provider section of the promptfoo documentation before you commit the config.
| Credential | CircleCI context or variable | Read by promptfoo config | Allowed jobs and branches | Rotation owner |
|---|---|---|---|---|
| Model provider API key (eval target) | Context llm-eval-prod, variable OPENAI_API_KEY (illustrative) | Provider entry in promptfooconfig.yaml, through the environment variable the provider expects | Eval job on main and release branches only | Platform engineering lead |
| Grader model API key (LLM-as-a-judge) | Context llm-eval-prod, separate grader key variable | defaultTest or assertion provider setting that points at the grader model | Eval job on main and pull requests from the same repository | Platform engineering lead |
| Red team attack generation key | Context llm-redteam, dedicated variable | redteam section of the config, provider setting for attack generation | Scheduled red team job on release branches only | Security engineering lead |
| Self-hosted or gateway endpoint token | Project variable scoped to the app repository | Custom HTTP provider headers that read the token from the environment | Eval job on main only, never on forked pull requests | Owner of the gateway service |
| Promptfoo Enterprise or cloud token (if used) | Context promptfoo-cloud, variable PROMPTFOO_API_KEY (confirm name) | Read by the CLI for result sharing, not by the eval config itself | Upload step on main only | Security engineering lead |
| Cache and result storage settings | Non-secret project variables, for example cache path | Cache directory settings used by the job and the cache step in config.yml | All eval jobs | Repository maintainer |
How a commit flows from CircleCI to model providers and back
The flow starts when a commit triggers a CircleCI pipeline and the job restores the promptfoo cache. promptfoo runs on the CircleCI runner and calls model providers over the network, using provider keys injected from a CircleCI context or project variables. Results are written locally, the cache is saved, and artifacts are stored for review. Check the boundary where requests leave the runner, because keys and prompt data cross it.
Trust boundary between the CircleCI runner and external provider APIs.
Hardening the CircleCI job and its secrets
A promptfoo job in CircleCI touches provider keys, prompts and model responses, so its controls matter as much as its YAML. The cards below cover who can run the job, which keys it can read, what the output exposes and what the job does not protect. Confirm each control against the current CircleCI and provider documentation before you rely on it.
Restrict contexts to approved branches
Store provider keys in a CircleCI context and attach that context only to jobs that run on protected branches or by approved security groups. A context can be restricted to named groups, so a feature branch cannot read production keys by editing the config. Check the context's restriction settings and the branch filters in your workflow, because a filter in the YAML alone does not limit who can start a job.
promptfoo CircleCI guideKeep fork pull requests away from keys
Pull requests from forks can trigger builds that run untrusted code, and a config that echoes secrets or calls providers could leak keys. Confirm how your CircleCI project handles builds from forked repositories, including whether secrets are passed to them by default. Run evals on fork builds without provider keys, or require a maintainer to approve those builds before keys are exposed.
Use least-privilege keys with spend caps
Create a separate provider key for CI with only the model access the eval needs, and set a spend limit or budget on it where the provider offers one. A leaked CI key then has a bounded blast radius and cannot reach production traffic. Ask each provider which spend, rate and model-scope controls its key types support, and record the answers in your configuration review.
Mask output and limit raw results
Eval results often contain full prompts, retrieved documents and model responses, which can include personal or confidential data. Keep raw result files out of public artifacts and build logs, and store only the reports reviewers need. Confirm how CircleCI stores job artifacts, who can download them and how long they are retained in your plan, and mask any values your prompts could echo.
Plan access for the self-hosted server
The self-hosted promptfoo app is not recommended for production. It stores data in a local SQLite database that cannot be shared across replicas, and it has no RBAC, built-in authentication or SSO. If a team views results there, place it behind your own access controls, and note that the CI job itself adds no authentication to the eval output it produces.
Self-hosting docsReview the setup each quarter
Contexts, branch filters, key scopes and artifact settings drift as teams add pipelines and providers. Schedule a review of who can access each context, which keys it holds and what the job uploads, and record the result. Ask your CircleCI administrator to export the current context and project settings so the review compares actual configuration, not what the YAML suggests.
Why the first CircleCI run fails and how to fix it
This table lists the failures teams most often hit on a first promptfoo run in CircleCI, with the likely cause and fix for each. Read it top to bottom when a job fails, and check the Node.js version and job context first, since those account for most early breaks.
| Failure | Likely cause | Fix |
|---|---|---|
| Node.js version too old | The image or installed Node.js is below 22.22.0, the minimum for the current promptfoo npm release | Use a CircleCI image with Node.js 22.22.0 or newer, then confirm the version with node --version as the first step of the job |
| Job cannot find the config or steps | The job is not defined in the workflow, or the checkout step is missing, so .circleci/config.yml is not read as expected | Add the job to the workflow and include a checkout step before the install and eval steps |
| Cache never restores | The cache key changes on every build, or the cached path does not match where promptfoo writes its cache | Build the key from a stable file checksum, confirm the path, and check the restore log on the next build |
| Provider rate limits or spend exhaustion | Concurrent test calls exceed the provider's limits, or the account has run out of credit | Lower concurrency, enable retries and backoff as described in the promptfoo operations guidance, and confirm the account budget with the provider |
| No egress to provider endpoints | The runner's network blocks outbound calls to the model provider, or a proxy is not configured | Confirm outbound HTTPS access from the runner to the provider host, and set any required proxy variables in the job |
| Keys printed to logs | A step echoes environment variables or a verbose flag prints request headers | Keep keys in a CircleCI context or project variable, remove echo steps, and rotate any key that appeared in a log |
Questions teams ask before running promptfoo in CircleCI
Is promptfoo free to run in CircleCI?
Yes, the promptfoo Community edition is free and includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month, with community support. Running the CLI in a CircleCI job falls under that edition. What you still pay for is the model API usage your evals and grader calls generate, billed by your provider, and the CircleCI minutes your jobs consume. Paid promptfoo Enterprise pricing is custom and is set through a sales conversation, so ask for a written quote if you need team sharing, SSO or continuous monitoring.
How much effort does a promptfoo CircleCI setup take?
The effort depends on a few drivers: how many model providers you test, how large your eval suite is, where your secrets live, and how closely your CircleCI setup follows internal standards such as shared orbs, contexts and approval gates. A single provider with a small suite is a short configuration exercise. Multiple providers, red team scans, cache tuning and reviewer-facing reports add work. Ask for a written scope that lists providers, suites and pipeline stages so the effort can be compared like for like.
Can our in-house team set up promptfoo in CircleCI without a partner?
Often yes, provided the team already runs CircleCI pipelines and can write Node.js-based jobs. The configuration in the CircleCI guide installs promptfoo and runs evaluations with caching between runs, so the core pattern is familiar to most platform teams. The work that tends to take longer is deciding who owns the eval suite, agreeing on pass-rate gates, and handling provider keys under your security policy. A partner is useful when those decisions need to be made quickly or reviewed by security and compliance teams.
What do we need to provide for a CircleCI promptfoo setup?
Plan to provide four things:
- Administrator or project-level access to the CircleCI organization and the repository that will hold
.circleci/config.yml - Provider API keys for each model service under test, stored in a CircleCI context or as project variables
- A sample eval suite, with prompts, test cases and assertions that reflect your application
- A named owner who can approve changes to the pipeline and the grading criteria
If you plan to run red team scans, also confirm which OWASP LLM Top 10 or internal risk categories matter to your application.
Do we need the self-hosted promptfoo server to run evals in CircleCI?
No. The promptfoo CLI runs evaluations locally on the CI machine and talks directly to the model providers you configure, so the job does not depend on a promptfoo server. The self-hosted app is an Express server with a web UI and API, deployable with Docker, Docker Compose or Kubernetes with Helm. It stores data in a local SQLite database that cannot be shared across replicas and lacks RBAC, built-in authentication and SSO, and the documentation says it is not recommended for production. Consider it only if you want a shared review interface, and plan for that separately from the pipeline.
How do we keep provider keys safe in CircleCI?
Store provider keys in a CircleCI context or as project environment variables, never in .circleci/config.yml or the repository. Restrict each context to the projects and branches that need it, and review who can read or change it. Confirm with your security team how key rotation, revocation and audit logging will work across your model providers, since those controls live partly outside CircleCI. Also decide whether forked pull requests should receive the keys at all.
Will promptfoo cache responses safely between CircleCI builds?
The CircleCI guide configures caching so results are reused between runs, which reduces repeated model calls for unchanged prompts and tests. Before you rely on it, confirm where the cache directory lives on the build image, how CircleCI cache keys are built, and when the cache should be invalidated after a prompt or model change. Cached outputs can also contain sensitive test data, so review what is stored and who can access the cache.
How DeployOpen scopes and delivers a CircleCI promptfoo integration
DeployOpen plans and builds the CircleCI setup for promptfoo inside your own CI environment, with the pipeline, caching and provider key handling agreed in writing before work starts. The result is a configuration your team can review, run and change after handover.
How we scope
- We confirm which promptfoo suites and red team scans the CircleCI pipeline must run, and on which branches.
- We agree how provider keys are stored in CircleCI contexts or project variables, and who can read them.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before any build begins.
How we build
- We write the
.circleci/config.ymljob, Node.js image, install step and promptfoo run command for your repository. - We configure caching of the promptfoo cache directory and test that a repeat build reuses stored responses.
- We set pass-rate thresholds, verify the job fails on regressions, and check the report artifacts reviewers receive.
How we hand over
- You receive the tested pipeline configuration, a short runbook and a record of the key and context decisions made.
- We document how to rotate provider keys, clear the cache, and update the promptfoo version used in CI.
- We walk your engineers through a live pipeline run so they can read results and troubleshoot a failed build.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- A retainer can cover promptfoo version upgrades, changes to suites and periodic review of the CircleCI setup.
- Ask any provider to confirm pricing, support terms and service levels in writing before you commit.

