Generating synthetic test cases with promptfoo

Use promptfoo generate dataset to widen a small LLM test set with persona-based cases, custom instructions and a provider you choose. Generated cases still need human review, so plan that effort before you rely on the suite.

On this page

Generating synthetic test cases with promptfoo when a handful of tests is not enough

promptfoo generate dataset expands a small seed set into more test cases using a model, and the output is candidate data that needs review before anyone relies on it. That matters most for a team with a handful of hand-written cases and a release approaching, because the immediate gap is usually breadth, and breadth is what generation adds. Generation fits well when you need broad input variety, persona coverage (for example, a first-time buyer, a frustrated repeat customer and a user writing in a second language) or an early suite that must exist before anyone has time to write every case by hand.

The limit comes from where the expected answers come from. The promptfoo introduction describes evals as running on your machine and talking directly with the LLM, so generation is a model call you configure and direct, and nothing in that setup verifies the expected answers it writes. For domain-specific expected answers, such as a fee rule, a dosage range or a claim-handling policy, a model can produce a fluent question with a confident but wrong answer, and only someone who knows the domain will notice. Regulated content and high-stakes outputs need the same treatment: keep those cases hand-written or expert-written, and use generation to widen the surrounding input variety.

Before you generate, settle three things. First, name the provider that will produce the cases, confirm its data terms cover the seed examples you send, and check that the seed set contains no customer records or regulated data. Second, agree who reviews the output and what they check: whether each input is something your users would plausibly send, whether each expected value is correct, and whether the case duplicates one you already have. Third, keep generated cases in a separate file or tagged group so reviewers can approve, edit or drop them without mixing them into your hand-written baseline. Ask your team to record how many generated cases were accepted, since that rate shows how much review the next batch will need.

Candidate cases pass a human gate before they join the suite

The diagram starts on your machine, where seed test cases and custom instructions are combined with persona prompts and passed to promptfoo generate dataset. That command sends the seed data to the generator provider you chose, which returns candidate cases. The review gate is the one point where a person accepts or rejects each candidate. Only accepted cases join the merged suite, and that suite then runs as an eval. Before you run generation, check what the provider receives and confirm its data handling terms, because the seed data leaves your machine at that boundary.

Seed data crosses to the provider; only accepted candidates reach the suite.

Generation options and when each one fits

This table compares the main inputs to promptfoo dataset generation and when each one fits. Read each row for the situation it suits and the cost it adds, such as review load, variety or data exposure. Confirm exact flags and config keys in the CLI help for the promptfoo release you run, since this page does not supply command syntax.

InputWhen it fitsTrade-off
Seed test setUse when you have a small set of reviewed cases that show input shape and expected answers.Generated cases inherit its style and blind spots, so a narrow seed gives narrow variety.
Persona definitionsYour users fall into distinct roles, such as analysts, customers or administrators, with different goals and wording.More personas widen coverage but add cases to review, so start with the roles that carry the most risk.
Custom instructionsThe generated cases must follow domain rules, languages, tone or output formats that the seed set does not show.Instructions steer output, but vague wording drifts, so every change needs a fresh review sample.
Generator providerUse a stronger model when case quality matters most, or a self-hosted model when prompts or seed data cannot leave your network.A hosted model sends seed data and instructions outside your network, so confirm its data handling terms before use.
Number of cases requestedA first pass to check quality before you commit to a larger run.Larger batches widen coverage but raise review load and the chance of near-duplicate cases.
Output fileReviewers need to diff, approve and track generated cases alongside the rest of the suite.Output sitting outside version control can be run by anyone without a recorded review.

Choosing the generator provider by data sensitivity

A hosted cloud model receives every generation request over the network, so the seed cases, persona instructions and any sample values you include in the prompt leave your environment for the provider's API. promptfoo runs on your machine or CI runner and calls the provider directly, so the provider's terms decide how that data is kept, alongside your own controls. Treat this path as an external transfer in your data classification review.

  • What leaves the network: the seed cases, custom instructions and any customer-like values pasted into them, plus the generated cases returned to you.
  • Retention and training: confirm whether prompts and outputs are stored, for how long, and whether they can be used to train models under the plan you hold.
  • Contract coverage: check that the account, region and data processing terms your security team reviewed are the ones your team actually uses.
  • Subprocessors and residency: ask where inference runs and which subprocessors touch requests, then compare the answers with your residency rules.
  • Output quality: frontier hosted models generally produce the widest range of persona cases with clean formatting, which usually means less regeneration work.

Before any production-like rows go in, get the retention and training terms in writing from the provider and confirm they match the classification of the seed data.

Setting up dataset generation step by step

This sequence takes you from a checked Node.js install to a reviewed, merged dataset and a recorded baseline eval. Each step ends with a check you can run, so generated cases are accepted only after a person has reviewed them. Run it with a small seed set and a small case count first, so every generated case can be read before it enters the suite.

  1. Confirm Node.js 22.22.0 or newer

    Check the Node.js version on the machine or CI runner that will call promptfoo. promptfoo 0.124.1 requires Node.js 22.22.0 or newer, so run node --version and confirm the output is v22.22.0 or higher. Run this check on the same host you will use for generation, since a laptop and a CI image often differ. Done when the version check passes and you have written the version into the run notes so the generation can be reproduced later.

  2. Install the pinned promptfoo release

    Install the CLI with npm install -g promptfoo@0.124.1 on the machine that runs generation, or add the same version as a dependency in the project that holds your configs so the lockfile records it. Pinning the version keeps generated output comparable between runs. If your organization mirrors the npm registry internally, confirm the mirror carries this release first. Done when promptfoo --version prints 0.124.1 from a fresh shell.

  3. Assemble a small seed set

    Write a small set of representative cases, each with the variables your prompt uses and an expected value or rubric that a domain owner has reviewed. Generated cases tend to inherit the assumptions in the seeds, so errors here carry into every later step. Keep the set small enough that one reviewer can read it in a single sitting. Done when each seed has a named reviewer's sign-off in version control and a spot-check confirms the expected values match intended product behavior.

  4. Configure one generator provider

    Set one provider for dataset generation in your config, choosing a model that your data handling rules allow to receive seed cases, because the seed cases are sent to that provider. Add persona settings and custom instructions only after the basic run works, so any failure has one cause. Done when a test request to the provider succeeds, which you can confirm by the call returning a response without authentication or quota errors in the output.

  5. Run generation with a small case count

    Run promptfoo generate dataset and request a small number of cases so the whole output fits in one review. Confirm the exact case-count option with promptfoo generate dataset --help, since flags can change between releases. Check that the number of cases written matches the number you requested, and that the command prints the path of the output file. Done when the count matches, the file exists, and every case has values for all variables the prompt expects.

  6. Inspect generated cases before accepting

    Read each generated case next to the seeds and the product rules. Look for expected values that contradict the seeds, personas that repeat one another, and inputs that exercise nothing the product does. Record accept, edit or reject for each case in a review file under version control, along with the reviewer's name. Done when every generated case has a decision and the accepted and rejected counts add up to the total from the previous step.

  7. Merge accepted cases into the suite

    Add accepted cases to the test set referenced by your config, and tag generated cases so they stay separate from seed cases in later reviews. Keep edited cases in the same review file so the history of each change stays visible. Run promptfoo eval once to confirm the file loads and every case executes. Done when the eval reports the expected number of test cases and no case fails because a variable is missing.

  8. Run a baseline eval and record it

    Run the full eval against the current prompt and provider, and save the output as the baseline for later comparison. Record the promptfoo version, the Node.js version, the generator provider and the evaluation provider in the run notes, because changing any of them changes results. Done when the run completes, its pass and fail counts are written down, and a rerun on unchanged inputs gives a comparable result.

Reviewing generated cases before trusting them

Treat every generated case as an unverified draft until a named reviewer has passed it through a gate. Start with duplicates and near-duplicates. Generators often reword the same scenario several times, so the row count overstates coverage. Group cases by the behavior they test and count the distinct groups. Next, look for leakage: if the generated prompt already contains the answer, the case measures whether the model can copy a hint, not whether it can reach the answer. Then compare difficulty with your seed set. If generated cases are consistently easier, a high pass rate says little about the production failures you care about. Record each finding against the case ID so each problem is found once.

The persona check catches the most convincing mistakes. A persona can sound plausible, such as a frustrated account holder or a junior claims clerk, and still never ask for the action your guardrail is supposed to block. Ask of each persona which failure it reaches, and drop or rewrite the ones that reach none. Plausible wording does not make a case correct. Expected values need separate treatment. Where the generator wrote a stated answer, treat it as an unverified hypothesis until a reviewer confirms it. Any case with a stated expected answer needs a reviewer with domain knowledge, such as a clinician for medication guidance or a credit analyst for lending rules, to check the answer against your own policy documents. If no one on the team can confirm it, mark the case as unverified and keep it out of pass-rate gates.

Keep a simple decision log so the review is auditable and the next run improves. For each generated case, record a case ID, its source, one decision (accept, edit or reject), the reviewer, a short reason and any fields changed. An illustrative review-log.csv might carry the columns case_id, decision, reviewer, reason and changed_fields. Store the log in version control next to the generated test file, so a case that later fails can be traced to who approved it and why. Reuse the reject reasons: if most rejections are leakage, add a constraint to your custom instructions for the next generation run and check whether leakage drops. Accept only cases that passed every check, and rerun the suite after each batch of edits to confirm the edited cases still behave as intended.

Security risks in generating test data with a model

Generating test cases means sending seed data to a model, writing the output to files and running a server that stores results. Each step can move sensitive content somewhere your organization has not reviewed. The five risks below name the control to confirm or apply before the first run.

Seed data reaches the generator

The generate dataset step sends your seed cases and custom instructions to the model provider named in your configuration. promptfoo runs on your machine and calls that provider directly, so the provider receives whatever the seed set contains. Personal data, customer records and confidential product text should be removed or replaced with invented values before generation. Confirm which provider and account will receive the prompt, and check that its use is approved for that class of data.

promptfoo introduction

Retention and training terms

A generated dataset is only as safe as the terms under which the generator handled the seed prompts. Retention periods, use of inputs for model training and processing locations can differ by provider, product tier and contract. Get the written terms for the exact model and account used for generation before any sensitive seed data is used. Ask the account owner which retention and training settings apply, and record the answers beside the evaluation plan.

Generated files in version control

Generated cases are written to files that look like ordinary test data, so they are easy to commit without review. A generated case can repeat a phrase from the seed set or include an identifier that looks plausible. Review every generated file before it is committed, and keep unreviewed output off the shared branch. Add the output directory to .gitignore when files should stay local, and run your secret and personal data scanning on the diff before merge.

Credentials in configuration files

The generator provider needs an API key, and that key often ends up in promptfooconfig.yaml or in a file copied from a template. A key committed to a repository is exposed to everyone with read access and to every clone made later. Read the key from an environment variable or your secrets manager, and confirm it is not written into generated files or stored results. Rotate any key that has been committed, and use a key scoped to the generation job.

Self-hosted server without RBAC

The self-hosted promptfoo server stores data in a local SQLite database and has no RBAC, built-in authentication or SSO. Its documentation says it is not recommended for production use. Do not share generated datasets there for team review unless other controls are in place, such as network restriction and an authenticating layer that you operate. Team access control and SSO belong to the paid Enterprise edition, so confirm with the vendor what your deployment includes.

Self-hosting docs

Keeping generated suites maintainable across runs

Commit the accepted generated file to version control, and have CI and developers run evals against that committed file instead of regenerating cases on every build. Each generation run calls the generator model again, and the model can return different cases even when the seed set and instructions stay the same. A build that regenerates can therefore fail for reasons unrelated to the application under test. Treat the committed file as the test suite: changes go through a pull request, and the reviewer checks the diff for cases added, removed or reworded. Regenerate only on purpose, and note the date and reason in the commit message. Ask your provider whether it lets you fix sampling settings, since that affects how closely reruns match each other.

Generation cost is provider usage, and it recurs every time someone runs promptfoo generate dataset. The promptfoo Community edition is free for LLM evaluation features and includes all model providers, so the software itself adds no license charge for this work. The generator model call is a separate bill from whichever provider your team selects, and its rate depends on that provider's pricing for the model you choose. Ask the platform owner which API key pays for generation, and set a spend limit on that key. Seed set changes add a second cost. Any edit to seed cases, personas or custom instructions can shift the generated batch, so the whole batch needs re-review, along with the new rows. Budget reviewer time for that, not only API calls.

Reviewers need to know which cases came from which generator settings. Keep a short run record next to the generated file that lists the provider and model name, the seed file version, the persona list, the custom instructions and the run date. If your generated output can carry a metadata field or comment on each case, use it, but confirm what the output format keeps before you rely on it. When a weak case appears in a later eval, this record tells you whether to fix one case by hand, rerun generation with changed instructions or retire the whole batch. Reviewers should also look for generated cases that duplicate seed cases or lean heavily on one persona, because those problems are easy to miss in a large batch and show up later as noisy eval results.

Limits to confirm in your environment before rollout

Each item below is a fact about your environment that the release and the vendor documentation may not settle for you. Confirm them in writing or with a test run on a small set of cases before you commit a planned case count or move any seed data outside your approved boundary.

Generation behavior and output format

Confirm how the promptfoo release you install runs promptfoo generate dataset, which file it writes, and how each generated case is structured. Output format can change between releases, so pin the version and check the file against your loader before any team depends on it. Run a small generation with your seed cases and compare the result to the vendor documentation. Keep the exact command and version in the repository so reruns produce comparable files.

Release notes

Expected values or inputs only

Confirm whether generated cases include an expected value for each input or only the prompt variables. If the output contains inputs only, every case still needs assertions written or generated separately, and a suite of inputs alone will not catch wrong answers. Check this with a test run on three or four cases from each persona, since the vendor docs may describe the field differently from what the file contains. Note which fields need manual completion.

Rate limits and token costs

Confirm the provider's rate limits for the model and account you plan to use, then calculate token use for your planned case count. Generation is only one part of the bill: every generated case later runs through evals, graders and any LLM-based assertions, so each case adds calls. Run a small batch, record input and output tokens, and extrapolate with the provider's current price sheet. Ask the platform owner which budget and quota the run draws from before scheduling it in CI.

Language and domain coverage

Confirm that the chosen model writes fluently in every language your users write in, and that it handles the domain terms in your persona and custom instructions. A model that handles English banking vocabulary may produce weaker or inaccurate cases in other languages or in specialist clinical or legal wording. Review a sample from each language and persona with a native speaker or domain expert, and note which combinations the model handles poorly. Those gaps tell you where to write cases by hand.

Provider data retention

Generation sends your seed cases, personas and custom instructions to the chosen provider, and those inputs may include customer or internal material. Confirm the provider's retention period, whether inputs are used for training, and which region processes requests, using its current terms and any enterprise agreement you hold. promptfoo itself runs locally and talks directly with the model, so the provider's terms govern what happens to these prompts. Get the answers in writing before seed data from production leaves your approved boundary.

Output paths in self-hosted and CI

Confirm where generated files are written when promptfoo runs in your CI job, on a developer laptop, or through the self-hosted server. Working directory, container volumes and CI workspace cleanup can move or delete the file, so a generated dataset may vanish before review. The self-hosted server keeps data in a local SQLite database that cannot be shared across replicas, so confirm which parts of the workflow depend on that single instance. Test the full path with one pipeline run and commit or archive the output deliberately.

Self-hosting docs

Questions teams ask before generating test cases with promptfoo

What drives the cost of expanding a test set with promptfoo?

The software has no license fee for generation. The Community edition is free and includes all LLM evaluation features, all model providers and integrations. Your real spend falls into three buckets: model calls made to your chosen provider to generate and grade cases (paid directly to that provider), seed set preparation, and reviewer hours. Provider spend rises with the number of cases generated, the length of each case and the model you select, so run a small batch first and measure it. Seed preparation and domain review are usually the larger line items. Costs are one-time for the seed set and setup, and recurring only when you regenerate cases on a schedule. In a quote, ask for the expected provider cost per batch, the reviewer hours by role, and whether the fee covers seed preparation, review support or both.

How long does a generated test case project take?

Duration depends mostly on how quickly your domain reviewers can work and how much seed material already exists. The generation run itself finishes once the provider responds, so it is rarely the bottleneck. The main drivers are the size and quality of the seed set, the number of personas and categories you need, the number of review rounds, and any access decisions made before work starts, such as provider approval, network routing to a private model and data classification review. Ask for the timeline as phases with dependencies: seed preparation, first generation batch, review, regeneration and handover into your pipeline. Each phase should name who must act and what they deliver, so you can check the schedule against your team's calendar. Any fixed end date belongs in the written scope, agreed before work begins.

What does our team need to provide for test case generation?

Your team supplies the inputs that only your organization knows. Plan for four items:

  • Seed cases that show typical inputs, expected behavior and the edge cases your application must handle.
  • Domain reviewers who can approve or reject generated cases in your business language.
  • Provider decisions: which model generates and grades cases, whether it is hosted or internal, and who holds the API key.
  • Data classification: which seed fields are personal, confidential or regulated, and whether they may leave your network.

Confirm the data classification with your security and privacy teams before the first run. Generation sends seed content to the chosen provider unless you route it to a model inside your environment, so this decision shapes everything else.

Can our team generate test cases without an outside partner?

Yes. A team with an engineer who can run the CLI, a reviewer who knows the domain and access to a model provider can do it alone. The Community edition is free and includes all LLM evaluation features, so the tool itself is not the barrier. The work that slows internal teams is usually review: deciding which generated cases are correct, removing duplicates and writing custom instructions that keep personas on topic. Outside help is most useful when reviewers are scarce, when provider and data decisions stall, or when the suite must be wired into CI/CD pipelines and shared reports. Test the decision with a pilot. Generate one small batch, have your reviewers grade it and record the hours. If review time exceeds what your team can spare, that result is a clear signal to scope outside help.

Do we need promptfoo Enterprise or On-Premise to generate test cases?

No. The Community edition is free and includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month. Enterprise adds team sharing, teams-based access control and SSO, custom roles and permissions, continuous monitoring, a centralized guardrail dashboard, remediation recommendations and priority support with SLAs. Enterprise pricing is custom. On-Premise runs the Enterprise functionality inside your own infrastructure with complete data isolation and a dedicated deployment engineer. Consider those editions only if you need shared access control, centralized reporting or a supported deployment for several teams. Confirm on the promptfoo pricing page that the features you need sit in the edition you choose.

What should a written scope for test case generation include?

A written scope should state what gets produced, who does what and how success is judged, all before work starts. Ask for these items:

  • The seed set size, source and format, and who supplies it.
  • The number of personas, categories and generated cases in the first deliverable.
  • The provider and model used for generation and grading, with the data classification for each input.
  • The review process: named reviewers, review rounds and acceptance criteria for a generated case.
  • Where the suite lives afterward, such as a repository, a CI pipeline or a self-hosted server, and who maintains it.
  • Handover items: configuration files, a runbook and a retest or regeneration step.
  • Fees, payment terms and how a change in scope is priced.

DeployOpen agrees scope, deliverables and timelines in writing before work starts, and a quote follows from that document.

How DeployOpen scopes and delivers test data generation

Most DeployOpen engagements are fixed-scope, so the scope for generated promptfoo test cases is agreed in writing before work starts. The work covers which prompts and test files get expanded, the personas and custom instructions that shape the new cases, the model provider used for generation, and the review step that decides which cases enter the suite. promptfoo runs locally, so evaluations run on your machine and talk directly with the model you choose.

How we scope

  • The written scope names the suite, prompts and test files that generated cases will expand.
  • It records the personas, custom instructions and model provider the generation step will use.
  • It sets the review criteria a generated case must meet before it joins the suite.

How we build

  • We connect promptfoo to the provider you chose for generation and confirm it runs from your environment.
  • We write persona definitions and custom instructions that match the users and risks in your application.
  • We expand a small seed set into generated cases, keeping the original cases and their assertions unchanged.

How we hand over

  • You receive the promptfoo configuration, generated test files and the persona and instruction files used to create them.
  • A review log marks which generated cases were accepted, edited or removed, and why.
  • The runbook covers regenerating cases, changing personas and reviewing new output before merging it.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer for suites that keep growing.
  • Upgrade checks cover promptfoo changes against your generated suite before a new version is used for generation.
  • Review criteria are revisited when the application, its users or its risks change.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.