Running garak scans in CI/CD pipelines

Learn how to add a short garak probe set to GitLab CI merge requests, gate a stage on the JSONL report, and keep secrets and harmful output out of job logs.

On this page

Running garak scans in CI/CD pipelines to catch LLM regressions before merge

A team that changes a system prompt, swaps a model or edits a guardrail needs a fast signal in every merge request, not only a full scan before release. A short garak probe set in the pipeline gives that signal, and a scheduled full scan covers the wider surface. garak, the Generative AI Red-teaming and Assessment Kit, is a command-line tool licensed under Apache 2.0 and installed from PyPI with pip. It requires Python 3.11 or newer and is developed on Linux and macOS, so the CI runner image should match those constraints. Each probe runs with its recommended detectors by default, and each run writes a JSONL report of every attempt and its evaluation, which is the file a pipeline stage can read to pass or fail.

Reading the JSONL report is what turns garak into a gate. Each attempt carries its evaluation, so the job can count failed probes against a threshold the team agrees in advance, and fail the stage when a regression crosses it. Before writing that logic, confirm the report fields in the garak version you pin, because output details can change between releases. Use a pinned version in the pipeline so a new garak release cannot silently shift the scores that gate merges. Keep the probe list small and fixed for merge requests, and choose probes that match what the change touches, such as prompt injection for a prompt edit or data leakage for a retrieval change. Confirm your probe selection and generation count with the garak user guide at docs.garak.ai before setting the threshold.

Use a pipeline gate for changes that alter model behavior and that reviewers merge frequently. Use a scheduled full scan for broad coverage, for longer probe sets, and for checks after a garak update, because those runs take longer and produce more requests against the target. The garak README describes the default of 5 generations per prompt, so a full run against a hosted endpoint can be far heavier than a merge request job. Agree the request volume and rate limits with the owner of the endpoint before the pipeline runs on every commit. Keep API keys in the CI secret store rather than in the repository, mask them in job output, and make sure the job log and stored artifacts do not print harmful prompts or outputs that the report contains.

A merge request becomes a pass or fail gate in four hand-offs

The flow starts when a merge request triggers a GitLab CI job on a runner. The job installs garak from PyPI and runs a short probe set against the target endpoint, with the endpoint credential read from the secret store inside the job. The job then reads the JSONL report, which is the only artifact the gate inspects, and sets the stage to pass or fail. Check that the report stays inside the protected artifact store and that the job log never prints prompts, outputs or keys.

Merge request flow from trigger to pass or fail, with the target endpoint and secrets inside a trust boundary.

Which garak settings to fix for CI and when each fits

This table compares the garak settings a CI pipeline has to fix: probe set size, generations, harness, target generator and report location. Read each row as a choice between a fast merge request gate and a broader scheduled run, and note the coverage each choice gives up.

SettingFits merge request gates whenTrade-off in time and coverage
Probe set sizeYou need a fast signal on every merge request and can list a few probe families that match the model's exposureA small probe set finishes sooner but misses families you did not select, so run a broader set on a schedule
Full probe runYou run on a nightly or weekly schedule against a stable build or a release candidateCovers far more attempts and takes much longer, so it should not block each merge request
Generations per prompt (default 5)You keep the default for scheduled runs where a single intermittent failure mattersFewer generations shorten the job but a probe can pass by chance, so confirm the reduced value still catches your known failures
Harness (default probewise)You want each probe run with its recommended detectors, which suits most CI gatesChanging the harness alters which detectors decide pass or fail, so keep it fixed between runs you compare
REST generator with YAML fileYour application or internal model endpoint is reachable from the runner and returns plaintext or JSONThe YAML file must match the endpoint's request and response shape, and it needs secrets injected at runtime, not committed
Hosted generator with credentialsThe model under test is a hosted API your team already calls from CIHosted endpoints add rate limits and cost per request, so confirm the rate and budget with the endpoint owner before setting parallelism
Report locationEach job writes its JSONL report to a job-scoped path that is saved as a pipeline artifactReports contain harmful prompts and outputs, so set retention and access deliberately; confirm the report path and prefix options for your garak version

Setting up a garak merge request stage in GitLab CI

This sequence adds a small, repeatable garak scan to every merge request so that a regression in model or application behavior is caught before code is merged. Each step produces an artifact or check that the next step depends on, so the stage can be trusted as a gate.

  1. Pin the garak version from the releases page

    Choose a specific garak release from the NVIDIA/garak releases page and record it in your pipeline configuration, for example as a CI variable named GARAK_VERSION. The release at the time of writing that is supplied for this topic is v0.17.1, released on 16 October 2026. Pinning matters because probe sets and detector scores can shift between releases, so a moving install would make merge request failures hard to explain. Confirm the latest release before you pin, and record the version in the job output. Done means the version string appears in the first lines of the job log and matches the release you reviewed.

  2. Create a CI job on a Python 3.11 image

    Add a dedicated job to .gitlab-ci.yml that runs only on merge request pipelines, using a container image with Python 3.11 or newer, since the PyPI package requires that version. Assign the job to a runner you control, so that prompts and model responses stay inside your network and you can review the runner's configuration. Keep the job separate from unit tests so a garak failure is easy to identify. Done means the job appears in merge request pipelines and prints the Python version before any garak command runs.

  3. Install garak from PyPI in a virtual environment

    In the job's before_script or first script line, create a virtual environment and install the pinned release with pip, for example pip install garak==<pinned version>. Installing into a venv inside the job workspace avoids mixing dependencies with the runner image and makes the install reproducible from one pipeline to the next. Cache the pip directory only if your runner policy allows it. Done means garak --version prints the pinned version, and the job fails early if it does not.

  4. Build the generator file from CI variables

    Write the garak generator configuration at job runtime from masked CI/CD variables, such as the endpoint URL and the API key for the target under test. The REST generator reads a short YAML file that describes the endpoint, so the job can render that file from a template and place it in the workspace. Mark the key variable as masked and protected, and avoid echoing the rendered file. Done means the job confirms the file exists and that the key value does not appear anywhere in the job log.

  5. Run the short probe set on the merge request

    Run garak against the generator with a fixed, small probe selection that the team has agreed for merge requests, and keep the same selection in every run so results are comparable. Set a fixed generation count and report directory so the output lands in a known path. The probe list is a team decision: choose probes that match the application's real exposure, and confirm with your security team which families are required. Done means the job exits and writes a JSONL report for the run, even if some probes fail.

  6. Store the report and log as job artifacts

    Declare the JSONL report and garak.log as artifacts with artifacts:paths and an explicit expiry, and set artifacts:when to always so they are kept when the scan fails. These files contain the prompts and model outputs that the scan produced, so treat them as sensitive: restrict who can download job artifacts in project settings and set a retention period that your data policy allows. Done means both files appear under the job's artifacts in the GitLab interface after a failed run.

  7. Add a script that reads the report and fails the stage

    Add a short script, for example a Python file in the repository, that parses the JSONL report line by line, counts entries whose evaluation marks an attempt as failed, and exits with a non-zero status when the count exceeds a threshold your team has set. Read the field names from a report produced by the pinned version, since field names can change between releases. Print only probe names and aggregate counts to the log, not prompt or output text. Done means the job turns red when the threshold is exceeded and green when it is not.

  8. Test with a deliberately weak illustrative target

    Before relying on the gate, point the stage at a deliberately weak illustrative target, such as a test endpoint that echoes unsafe content or has no system prompt, and confirm that the job fails with the expected probe families flagged. Then point it at a target you expect to pass and confirm the job is green. Run both checks on a throwaway branch and record the results. Done means the failing and passing runs behave as designed, and the team can explain why each probe was flagged.

Turning the JSONL report into a pass or fail rule

garak reports results per probe, not per pipeline, so the pass or fail decision for a CI stage is a rule you write and own. The cards below cover how garak marks a probe as failed, how to set a threshold, how to read the report safely, and how to keep the rule stable across garak upgrades.

Understanding the default FAIL rule

garak makes 5 generations per prompt by default and marks a probe as FAIL when any attempt produces undesirable output. That is a strict signal: one bad completion out of five fails the whole probe. Before you copy that behavior into a merge request gate, decide whether one stray output should block a merge or whether you need a rate. Check the generation count in your config, because changing it changes how sensitive the gate is.

garak README

Threshold on failure rate or any failure

A gate can block on any failed probe, or only when a probe's failure rate crosses a limit you set. Any-failure gates are simple and fail closed, but they can block on noise from a small probe set. Failure-rate gates tolerate isolated hits but need a documented limit that security and the model owner agree on. Record which approach you chose and why, because auditors and reviewers will ask how the number was picked.

Parsing each attempt record

The JSONL report holds one record per attempt, each with its evaluation. Your parser should read the probe name, the detector, the status of each attempt and the failure count rather than scanning raw text. Write the parser to fail loudly when a field is missing or renamed, so a format change cannot silently turn into a pass. Keep the parser in the repository next to the pipeline definition and test it against a saved sample report.

Separating errors from passes

A probe that errors out is not the same as a probe that passed. Timeouts, rejected credentials or a dropped endpoint can leave attempts unevaluated, and a naive parser counts them as clean. Treat missing or errored attempts as a stage failure or a separate warning state, and make the job print the count of unevaluated attempts. Ask the endpoint owner what error responses look like before you trust a green result.

Versioning the gate rule

The gate script, its thresholds and the probe list should live in the same repository as the pipeline definition and change through merge requests. When a threshold changes, the history should show who changed it and why. Pin the garak version in the pipeline so a rule tested against one release does not run against another without review. Store the rule's version in the job output so each result can be traced to the logic that produced it.

Re-baselining after an upgrade

Scores can shift after a garak upgrade because probes, detectors or default settings change. When you move to a new release, run the pinned probe set on the old and new versions against the same target, compare the results and note any probes whose status changed. Adjust thresholds only with a recorded reason, and keep the previous baseline so you can explain a sudden jump in failures to the team that owns the model.

garak releases

Questions teams ask before adding garak to CI

What does adding garak to a CI pipeline involve?

Adding garak to CI means installing it from PyPI in a job, pointing it at a target generator, running a short probe set on each merge request, and reading the JSONL report to decide whether the stage passes. The work covers the job definition, the generator configuration for your endpoint, the pass or fail rule, and how secrets and harmful output stay out of job logs. garak is free and licensed under Apache 2.0, and the PyPI package requires Python 3.11 or newer. Your team owns the decision about which probes block a merge, while an implementation partner can design and test that setup if you prefer to hand it off.

What drives the cost of running garak in CI?

Cost has four main parts: runner time, calls to the target endpoint, model API or GPU charges, and staff time. Runner time grows with probe count, generations per prompt and how long each request takes. Endpoint and API charges depend on request volume, so a short per-merge probe set costs far less than a full scan on every commit. GPU charges apply when the model under test runs on your hardware. One-time costs are the pipeline build and the review of the first results. Recurring costs are the runner minutes, the endpoint usage and the periodic review of the probe set. Ask any quote to separate these lines and state the request count each job generates.

Does GitLab cost money if we only need CI runners?

GitLab's pricing page lists GitLab Free at 0 US dollars, Premium at 29 US dollars per user per month billed annually, and Ultimate as custom priced. All three tiers are available for self-managed installations. The pricing page lists advanced CI/CD and priority support for Premium, and application security testing, software supply chain security, vulnerability management and compliance features for Ultimate. A garak job can run on a GitLab Runner under any tier, so the tier decision depends on your other CI and security needs, not on garak itself. Confirm current prices on the GitLab pricing page before budgeting, since prices change.

How long does it take to set up garak in CI?

Setup time depends mainly on how complex the target endpoint is. A plain REST endpoint that returns plaintext or JSON needs a short YAML file describing the endpoint, plus credentials passed as CI variables. An endpoint behind single sign-on, client certificates, a proxy or a guardrail layer needs more testing, and each extra layer adds discovery and verification work. Plan for a first pipeline run, a review of the report format, and a dry run on a non-production endpoint before any merge request blocks on the result. No duration is quoted here because it varies by environment. Ask a partner for a written timeline based on your endpoint and your runner setup.

What must our team provide before the engagement starts?

Your team needs to provide four things. First, network access from the GitLab Runner to the target endpoint. Second, test credentials with the narrowest permissions that allow the scan, stored as protected CI variables. Third, written approval from the owner of the endpoint for the request rate and the daily or per-merge volume garak will generate, because a scan can look like an attack to the endpoint's monitoring. Fourth, a named owner who decides which probe failures block a merge and who triages the results. Confirm with the endpoint owner whether rate limits apply and what happens when requests are dropped.

Can our own engineers build garak CI pipelines in-house?

Yes, if your engineers already run GitLab CI and can write a generator configuration for your endpoint. garak is a command-line tool installed with pip, and the pipeline itself is a standard job definition. The skills that take longer are reading the JSONL report correctly, choosing a pass or fail threshold that does not block every merge on noise, and keeping harmful prompts and outputs out of job logs and artifacts. Teams that build in-house usually start with a single endpoint and a small probe set, then widen it after reviewing several runs. A partner is most useful when the endpoint is complex or when an auditor will review the evidence.

How often should we review the garak probe set in CI?

Review the probe set whenever the model, system prompt, guardrail or tools behind the endpoint change, and whenever you upgrade garak. Releases can change probe behavior and scores, so pin the version in your pipeline and read the release notes at garak's GitHub releases before moving to a newer one. For a fixed cadence, many teams review the blocking probe list each quarter and after each upgrade. Keep a record of each change and the reason for it, so a score shift can be traced to a configuration change or to a new release rather than to the model.

Will garak output expose harmful content in our job logs?

It can, if the job prints the full attempt records to the console or uploads them as public artifacts. garak writes a JSONL report of every attempt and its evaluation, plus a garak.log file that continues across runs, so both need deliberate handling. Keep API keys in masked, protected CI variables and never echo them in the script. Store reports as restricted job artifacts with short expiry, print only the summary result to the log, and avoid passing credentials on the command line where they appear in logs. Treat the report as sensitive because it contains the prompts and outputs that the probes triggered.

Security and operational considerations for scans in CI

A garak job in CI touches model credentials, target endpoints, prompts that may elicit harmful output, and shared infrastructure. The cards below cover the decisions that connect these risks: where the job runs, what it can reach, how much traffic it sends, how long its artifacts live, who can trigger it, and how the probe set stays current after upgrades.

Trust boundaries of shared runners

A shared runner may execute jobs from many projects, and any job on it can read files, environment variables and cached data left by earlier jobs. Confirm which projects share a runner before a garak job receives model credentials. Prefer a dedicated runner with a tag restricted to the scan project, and make sure the job workspace is cleaned between runs. Ask whether the runner host persists anything across jobs, since a leftover key or report could expose harmful test content to other teams.

GitLab Runner docs

Least-privilege access to the target

The CI job needs only the credentials required to call the endpoint under test, scoped to a test or staging deployment. Create a dedicated service identity with the narrowest model or API permissions, rather than reusing a developer or production key. Store the key as a masked, protected CI/CD variable so it is not echoed in job output, and rotate it on a schedule your security team sets.

Scan traffic agreed with the endpoint owner

Every merge request that triggers a scan sends many prompts to the target, which may be a shared inference service with its own rate limits and cost. Agree in advance how many concurrent jobs may run, how many requests a short scan sends, and which team is notified when scans fail. Ask the endpoint owner how dropped or throttled requests appear in their logs, so that scan noise is not mistaken for an attack.

Report and log retention

garak writes a JSONL report of every attempt and its evaluation, plus a garak.log file that continues across runs. These files can contain harmful prompts and model outputs. Set the CI artifact expiry to the shortest period your review process needs, and restrict who can download artifacts from the project. Keep scan output out of the public job log, and confirm with your legal and security teams how long archived reports may be kept.

garak user guide

Fork and external merge request handling

Merge requests from forks or external contributors can change the pipeline definition, the probe configuration or the endpoint URL they target. Do not expose model credentials to pipelines triggered by untrusted sources. Confirm your GitLab settings so that protected variables are available only to protected branches, and require that scan jobs for external changes run in a restricted context or wait for maintainer approval before they start.

Recurring review of probe sets

garak releases change probe sets and scoring, so a pipeline that passed on one version may fail on the next without any change to the model. Pin the garak version in the pipeline, record it with each report, and review the probe list whenever you upgrade. Compare a sample of results between the old and new versions before you change pass or fail thresholds, and assign an owner for that review.

garak releases

What the team owns after the first gate goes live

Once the merge request gate runs, the team owns its behavior over time. The first job is tuning the probe set. Start with the short set that fits the application's real exposure, then review which probes produce noise, which catch real regressions and whether any probe no longer matches how the application is used. Record every change to the probe list, generations setting and pass threshold in the repository, so a failing merge request can be traced to a configuration change rather than to a model change alone. Confirm with the owners of the target endpoint how often the gate hits it, because a busy merge request queue can turn a small probe set into a steady load on a shared model.

The garak version is pinned in the pipeline, and the pin should change only through a planned review. Install the release you have tested, read the release notes for the version you intend to move to, and rerun the gate against a known application build before merging the bump. Scores can move after an upgrade even when the application has not changed, so treat the first run on a new version as a new baseline. Check the garak releases page when planning the review, and confirm the minimum Python version your runners provide before changing the pin.

Flaky gates are the most common reason teams lose trust in an AI security check. A gate that fails on one run and passes on the next either teaches developers to ignore it or blocks work for no reason. Track failure rates per probe across recent pipeline runs, and separate infrastructure failures such as timeouts, rate-limit responses and dropped connections from genuine FAIL results. When a result is unstable, adjust the generation count or the prompt set before loosening the threshold. Decide in advance when results move from the merge request gate to a scheduled full run, based on how often the gate catches issues and how long a full run takes on your runners. Scheduling and wider scan coverage are covered in the separate scheduling guidance for garak.

Official sources for garak and GitLab CI

The cards below point to the primary sources for the garak version, install path, and report format used in a merge request scan, plus the GitLab Runner and pricing documentation that govern where the job runs. Check each one before you pin a version or pick a runner tier, because both projects change between releases.

garak README

The README on GitHub is the starting point for what garak probes, how its plugins are organized, and what it writes at the end of a run. Read the sections on the default harness and the JSONL report before you write a pass or fail rule, since the stage gate depends on those exact fields. Confirm that the probes you select still exist in the release you install, because probe names can change between versions.

garak README

garak releases

The releases page lists the version notes that tell you what changed in detectors, probes and report formats. Pin the exact version in your pipeline file and read its notes before you upgrade, because a new release can shift scores and break a parser that reads the report. Keep a record of the version used for each merge request so that failures can be traced back to the scanner rather than the model.

garak releases

garak on PyPI

The PyPI page gives the package name, the supported Python versions and the install command that a CI job will run. Install with a version constraint instead of an open range, and confirm that your GitLab Runner image provides a Python version the package supports. Check the dependency list before you cache a virtual environment, since a cached environment keeps old versions until someone clears it.

Minimum Python version
3.11
garak on PyPI

garak user guide

The user guide explains how to select probes, set generations and write a configuration file that a pipeline can reuse. Use it to decide which short probe set fits a merge request and which longer set runs on a schedule. Look for the guidance on the report directory and log files, because CI jobs need to know where artifacts land before they can expire or upload them.

garak user guide

GitLab Runner documentation

The Runner documentation covers executors, tags, concurrency and how jobs get their environment variables. Choose an executor that can reach your model endpoint from the network where the runner sits, and confirm that masked variables stay masked in job logs for your Runner version. Check the security notes on shared runners before you let merge request pipelines from forks use a runner that holds secrets.

GitLab Runner docs

GitLab pricing page

The pricing page lists which CI/CD and security features each tier includes for self-managed installations. Confirm the tier you need before you plan on features such as pipeline security reports or compliance controls for merge requests. The Free tier can run a garak job through GitLab CI, but the scan cost itself comes from the model endpoint and runner compute, so ask your team to price those separately.

Free tier price
$0
GitLab pricing

How DeployOpen works on this

DeployOpen scopes garak CI gates as a written, fixed-scope engagement covering the pipeline, probe set, pass or fail rules and runner environment in infrastructure you control. The work is built, tested and handed over with documentation so your team can run and adjust the gate after delivery.

How we scope

  • Confirm which GitLab instance, runners and branches the garak merge request stage will run on
  • Agree the probe set, generator target and pass or fail threshold read from the JSONL report
  • Define how secrets, API keys and harmful output are kept out of job logs and artifacts

How we build

  • Install garak from PyPI in a pinned job image on Python 3.11 or newer
  • Configure the REST or hosted generator with credentials injected from your secrets store
  • Test the stage against known-bad and known-good model behavior before enabling it on merge requests

How we hand over

  • Deliver the pipeline configuration, pass or fail script and a short runbook for your engineers
  • Document how to change the probe set, rerun a failed stage and read the JSONL report
  • Walk your platform and security teams through the gate, its limits and its logging controls

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer after handover
  • Plan a review of the gate when garak releases a new version and the gate needs retesting
  • Confirm with your team what evidence, retention and access rules apply to stored scan artifacts

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.