Scanning Hugging Face models and Inference Endpoints with garak

garak offers three Hugging Face generators: a local transformers pipeline, the Inference API and a private Inference Endpoint. This page explains how to choose one, configure tokens and gated access, and plan disk and memory.

On this page

How garak scans Hugging Face models and endpoints

A team that must test a Hugging Face model or endpoint before release connects garak through its Hugging Face generators: --target_type huggingface for local transformers pipelines, huggingface.InferenceAPI for API access, and huggingface.InferenceEndpoint for a private endpoint the team runs. garak is licensed under Apache 2.0, is installed from PyPI with pip, and requires Python 3.11 or newer. Read the NVIDIA/garak README before choosing a generator, because the README defines the target types and the authentication options that the rest of this page assumes.

Authentication is optional for some paths but matters for others. Set HF_INFERENCE_TOKEN to a Hugging Face token with the read role so requests to the Inference API or a private endpoint authenticate under a named account. Confirm the token scope with your Hugging Face administrator before the first run, and confirm that the account can see the endpoint or model. Do not store the token in a scan configuration file that is committed to source control. Keep it in the environment of the host or CI runner, and rotate it on the schedule your secrets policy sets.

The generator choice follows where the model runs and who controls it. A local pipeline keeps prompts and outputs on your hardware, which suits models that cannot leave your network, but it moves the compute and storage cost to your team. A private Inference Endpoint keeps the model on infrastructure your organization has contracted, and the scan then tests the same deployment your users reach. Check with the endpoint owner which model revision and configuration are deployed, because a scan of a different revision produces results that do not describe the release.

What you need before the first Hugging Face scan

Four things decide whether the first scan starts cleanly: the Python and garak install, a Hugging Face token with the right role, license acceptance for any gated model, and enough disk and memory for what you plan to run locally. Check each one before the scan window opens, not during it.

Python 3.11 and a pip install

garak is a command-line tool installed from PyPI with pip, and the PyPI package requires Python 3.11 or newer. garak is developed on Linux and macOS, so confirm your interpreter version and OS before you build a scan host. Install into a dedicated virtual environment so the scan's dependencies stay separate from other tooling on the same machine.

garak on PyPI

Read-role Hugging Face token

The Hugging Face generators can authenticate with an HF_INFERENCE_TOKEN environment variable, and the token should carry the read role. Create it under the account that is allowed to use the models you plan to test, and store it in your secrets manager rather than in a shell history or a committed config file. Confirm with your security team who owns the token and how it rotates.

garak README

License acceptance for gated models

Some models on the Hub are gated, which means you must log in to Hugging Face and, in some cases, accept the model provider's license terms before the weights or inference are available to your account. Check each model page before planning the run, and record who accepted which terms. A scan against a gated model that fails on access is a planning gap, not a tool fault.

garak FAQ

Disk space for dependencies

The garak FAQ notes that garak may pull in about 9 GB of dependencies on a plain OS install, before any model is downloaded. Size the host for that baseline, then add the full size of each model you run locally, plus space for JSONL reports and the continuing garak.log file. Ask your platform team to confirm the volume and its growth policy before the host is provisioned.

garak FAQ

Memory and GPU for local models

Memory and GPU requirements depend on the specific model, its precision and the runtime you choose, so they cannot be assumed from garak's install size. Read the model card for its stated hardware needs, then compare those figures with the host you have. Inference Endpoints and the Inference API move that load to Hugging Face's infrastructure, which changes the sizing question to one about endpoint capacity and rate limits.

garak user guide

Reports and logs storage plan

Each run writes a JSONL report of every attempt and its evaluation, and garak keeps appending to a garak.log file across runs. With the default of 5 generations per prompt, report size grows with the probe count and the number of repeated runs. Decide where reports are kept, how long they are retained and who can read them, because they can contain model outputs that reflect sensitive prompts.

garak README

How a garak run reaches Hugging Face

The run starts on the operator's host, where garak reads the target type and chooses one of three generator paths. The local transformers pipeline keeps model inference on the host, while the Inference API and private Inference Endpoint paths send prompts to a Hugging Face service or an endpoint you place. The optional HF_INFERENCE_TOKEN is passed on the API and endpoint paths only, so check which side of the trust boundary each path crosses before scanning. Every attempt and its evaluation lands in the local JSONL report and the garak.log file.

Three generator paths from one garak host, with the trust boundary to external services marked.

Which Hugging Face generator fits your model

Use the local huggingface generator (selected with --target_type huggingface) when the model weights can be loaded onto the host that runs garak. The model executes in a transformers pipeline on that machine, so prompts and completions stay on the host. This is the option that fits models you must keep inside your boundary, including models under license terms that restrict hosted use.

  • Disk and memory: The model files must fit on local storage, and the host must hold the model in memory. Plan for the model size plus the garak dependencies, which the garak FAQ notes can add about 9 GB on a plain OS install.
  • Hardware: Scan speed depends on whether the host has suitable accelerators or runs on CPU alone, so benchmark a small probe set before planning a full run.
  • Data exposure: No prompts leave the host through this generator, which simplifies data handling review.
  • Gated models: Gated repositories need a Hugging Face login and, in some cases, acceptance of the provider's license terms before the download succeeds.
  • Scan speed drivers: Model size, precision, batch behavior and the number of generations per prompt (5 by default) set the run time.

Confirm with the model provider which license terms apply to local hosting, and confirm with your platform owner that the host has the disk, memory and network policy the download requires.

How gated models and tokens change the scan plan

Gated models need an access decision before the first scan. Some Hugging Face models require a Hugging Face login and, in some cases, acceptance of the model provider's license terms before the account can download or use them. garak's FAQ notes this requirement, so the scan plan has to name the account that will hold access before any run is scheduled. That account is the one that must accept the terms, and the token that garak reads through HF_INFERENCE_TOKEN inherits whatever rights that account has. Teams should confirm with the model provider which accounts may accept terms on the organization's behalf, and whether acceptance is recorded against a named individual or an organization account.

A shared personal token creates a governance problem that is hard to fix later. If a scan runs under one engineer's token, the license acceptance, the audit trail on the Hub and the ability to keep scanning all depend on that person staying in the role. Scan jobs in CI or on a scheduled host then fail when that person leaves or rotates credentials, and nobody can show who accepted the terms. Plan a service account or a dedicated organization identity for scanning, grant it the read role that the README describes, and store the token in your secrets manager rather than in a shell profile or a config file committed to a repository.

Set ownership, rotation and removal rules before the first scan, and write them down. Name an owner for the token, set a rotation interval your security team approves, and define who revokes the token and removes the scan host's access when a person or project ends. Confirm the license terms of any commercial model with your legal team before scanning it, because a scan is still a use of the model and terms may restrict it. Ask legal whether the terms cover security testing, internal evaluation or publication of results, and record their answer alongside the scan plan.

Configure a scan against a Hugging Face target

This sequence takes a team from a cleared Hugging Face account and access terms to a completed garak scan against the generator path it chose, with a test run and a saved report at each stage. The engineer running it should be able to repeat the setup on another host.

  1. Create a read-role token and store it

    The security or platform engineer who owns the Hugging Face account creates an access token with the read role, then saves it in the organization's secrets manager under a name the scan host can retrieve. Do not paste the token into a shell history, a config file committed to source control, or a shared ticket. The step is done when the token appears in the secrets manager, the owner has confirmed it carries only the read role, and the scan host can fetch it without a plain-text copy on a laptop.

  2. Accept the model license and confirm access

    For a gated model, the engineer signs in to Hugging Face with the account that will run the scan and accepts the model provider's license terms on the model page if the provider requires it. Involve legal or the compliance lead if the license restricts security testing or commercial use. The step is done when the model page loads for that account without an access prompt and the license acceptance is recorded in your change log.

  3. Install garak in a virtual environment

    On a Linux or macOS host with Python 3.11 or newer, the engineer creates a dedicated virtual environment and installs garak from PyPI with pip. Plan for garak to pull in a large set of dependencies on a plain OS install, plus the size of any model you run locally, so confirm disk space before you start. The step is done when garak reports its version from inside the environment and the version matches the release your team has approved.

  4. Choose the generator path

    The engineer selects one of the three Hugging Face paths: the local transformers pipeline for a model that runs on your hardware, the Inference API for hosted access, or a private Inference Endpoint for a model deployed in your Hugging Face tenancy. Record the choice and the reason in the scan plan, because the path determines whether a token is needed, where the model runs and how much disk and memory the host needs. The step is done when the plan names one path and the approver has signed off on where the prompts and responses will travel.

  5. Set the token variable for the chosen path

    For the Inference API or a private Inference Endpoint, the engineer exports HF_INFERENCE_TOKEN in the scan session, loading the value from the secrets manager rather than typing it. The local pipeline path usually needs the variable only when the model download is gated. The step is done when the variable is set in the current session, the value is absent from the shell history and any saved script, and a simple authenticated request to the model succeeds.

  6. Run a short test probe

    The engineer runs one small probe with a single generation per prompt against the target, using the generator flags for the chosen path. Confirm the exact flag names and model identifiers in the garak user guide before running, since those values change between releases. The step is done when the target returns responses without authentication or model-loading errors, and the console shows the probe completing.

  7. Run the wider scan

    The engineer runs the planned probe set with the default generation count, or the count the scan plan specifies, and lets the run finish without interruption. Keep the run on a host with the memory and disk the local path needs, and note the start time and parameters in the scan record. The step is done when the run ends with a summary of probe results and no unexplained generator errors.

  8. Confirm the JSONL report and garak.log

    The engineer checks the output directory for the JSONL report, which records every attempt and its evaluation, and for garak.log, which continues across runs. Archive both files with the scan record and keep the garak.log from earlier runs for debugging comparisons. The step is done when both files exist, the JSONL file contains entries for the probes that ran, and the log shows no unhandled exceptions from the test run.

Mapping Hugging Face concepts to garak settings

This table maps each Hugging Face concept you will use in a scan to the garak setting that consumes it. Read each row as a handoff: the item on the left is what your team or the model provider controls, and the right column is what to confirm before the first run. Most failed scans trace back to a token, license or endpoint detail that was assumed rather than checked.

Hugging Face conceptgarak setting or targetOwner and what to confirm
Model identifierTarget name the chosen generator expects, passed with the model name option for the pipeline, API or endpoint targetYour scan engineer. Confirm the exact repository name and that it matches the generator's expected format.
Access tokenHF_INFERENCE_TOKEN, used for the Inference API and Inference Endpoint targetsAccount owner. Create a token with the read role only and confirm it is stored in your secrets manager, not in a config file.
Gated license acceptanceNo garak setting. The Hugging Face account that runs the scan must already be logged in and have accepted the licenseModel provider terms and your legal or procurement team. Confirm the scanning account, not the requester, accepted the terms.
Endpoint URL and deploymenthuggingface.InferenceEndpoint target, pointed at your private endpointPlatform team. Confirm the endpoint is running, its region and network access rules, and that the token can reach it.
Hosted API accesshuggingface.InferenceAPI targetPlatform team. Confirm the model is served through the Inference API for your account and that rate limits suit your planned probe volume.
Model weights on diskLocal transformers pipeline path, selected with the huggingface target typeInfrastructure team. Confirm the weights are downloaded to an approved location with enough free disk space and memory for the model.
Dependency footprintInstalled garak environment and any local model cacheInfrastructure team. The garak FAQ notes about 9 GB of dependencies on a plain OS install, plus the size of any model run locally.
Run logs and reportsPer-run JSONL report and the continued garak.log fileSecurity reviewer. Confirm where these files are stored, who can read them, and that tokens are not written into them.

Protecting tokens, prompts and reports

A Hugging Face scan touches credentials, live endpoints, attack prompts and cached model files, and each one can leak data if handled casually. The cards below cover the controls to set before the first run and the questions to settle with your security team.

Use a read-only token

Create the Hugging Face token with the read role only, since garak needs to download models and call inference but never needs to write to repositories or manage an organization. Pass it through the HF_INFERENCE_TOKEN environment variable rather than hard-coding it in a command. Confirm with the security team which account owns the token, how it is rotated, and whether the organization's token policy allows fine-grained tokens scoped to specific endpoints.

garak README

Keep tokens out of history and repos

Shell history, shell profiles and garak configuration files are common places where tokens persist unnoticed. Load the token from a secrets manager or a session-only environment variable, and keep any garak config that references it out of version control. Add the config file and report directories to .gitignore and run a secret scanner on the repository before the first commit. Confirm with the security team where approved secrets live and who can read them.

Restrict endpoint exposure

A private Inference Endpoint or a self-hosted model reachable from the scan host should not be reachable from the wider network. Confirm that the endpoint's access settings allow only the scan host or its egress range, and that no public URL is left active after testing. Also confirm whether the endpoint's logs record prompts, since garak's attack traffic will appear there as well as in local reports.

Treat reports as sensitive data

Each run writes a JSONL report with every attack prompt and model output, and the garak.log file accumulates debugging detail across runs. Outputs can echo fragments of training data, system prompts or customer text, so store these files with the same classification as the application under test. Set file permissions on the report directory, restrict who can share the output, and agree a retention period with the security team before scans begin.

garak user guide

Clean up on shared hosts

Model weights downloaded from the Hub are cached on disk and remain there after the scan, so other users of a shared GPU server or build runner may find them. Set the cache location deliberately, check the license terms of each gated model before it is stored, and remove cached weights and logs when the engagement ends. Confirm with the platform team which directories are shared, which are wiped between jobs, and whether the host is allowed to hold gated model files at all.

Common Hugging Face scan failures and fixes

This table lists the failures teams most often hit when running garak against Hugging Face models or Inference Endpoints, with the likely cause tied to a setup step and the fix. Read it by matching the error you see to a row, then checking the token, license acceptance, disk, memory, endpoint path or report file that the row names.

FailureLikely causeFix
Authentication error when calling the Inference API or EndpointHF_INFERENCE_TOKEN is missing from the shell that launched garak, or it holds a token with the wrong role or an expired valueExport HF_INFERENCE_TOKEN in the same session, create a token with the read role, and confirm the account can see the model page
Gated model access deniedThe Hugging Face account behind the token has not accepted the model provider's license termsLog in with that account on the model page, accept the terms, then retry with the same token; the FAQ notes this is required for some gated models
Model downloads fail or stop partwayThe host is not logged in to Hugging Face, so gated files are refusedRun a Hugging Face login on the scan host with the account that accepted the license, then confirm the download works outside garak
Dependency install fails on a plain OSThe disk lacks room for the dependencies, which the garak FAQ says may reach about 9 GB on a plain OS installCheck free space on the volume holding the Python environment before installing, and move the environment or cache to a larger volume
Local transformers run exhausts memory or diskThe model weights, plus the Hugging Face cache, exceed the RAM or GPU memory on the hostCheck the model's size before the run, point the cache at a volume with room for the weights, and choose a smaller model or a hosted generator
Inference Endpoint unreachable or returning errorsNetwork path blocks the endpoint URL, the endpoint is paused or scaled to zero, or the scan host has no route to itConfirm the endpoint is running and reachable from the scan host with a simple request, then check proxy, firewall and DNS settings on that path
Report missing attempts after an interrupted runThe run stopped before all attempts were written, and the JSONL report reflects only completed attemptsTreat the report as partial, check garak.log for where the run stopped, and rerun the probe set so results are complete before comparing scores

Questions buyers ask before scanning Hugging Face models

What drives the cost of scanning a Hugging Face model with garak?

The cost comes from four places: the time your engineers spend on setup and triage, the compute needed to run a model locally, the hosting you pay for when you use a private Inference Endpoint, and the licensing and token administration around gated models. garak itself is a free tool under the Apache 2.0 license, so the license fee is not the main cost. Local runs cost more in hardware and disk, while endpoint runs shift cost to the hosting provider's billing for the time the endpoint is running. Ask any partner to break its quote into these components so you can see which parts recur and which are one-time. DeployOpen quotes follow from a written scope, and the scope lists which of these costs you carry.

How long does setup take for a Hugging Face scan?

No fixed duration applies, because setup length depends on the number of models, the target type, and how many access questions must be settled first. A single public model on a local pipeline can be set up quickly by an engineer who already runs Python tools. Gated models, private endpoints, network rules and disk planning add steps that take longer. Confirm the timeline in writing with any provider, and ask which steps depend on your approvals, such as license acceptance or token issuance. garak needs Python 3.11 or newer, so check your host's Python version before you start counting days.

What does the work require from our team before a scan starts?

Four things need to be settled before the scan runs:

  • Token ownership: decide whose Hugging Face account issues the HF_INFERENCE_TOKEN, which should carry the read role, and who rotates it.
  • License decisions: confirm that someone with authority accepts any model provider license terms that gated models require.
  • Network access: confirm the scan host can reach the Hugging Face Hub, the Inference API, or your private Inference Endpoint.
  • Disk and host access: confirm the host has room for garak's dependencies, which the garak FAQ says may reach about 9 GB on a plain OS install, plus the size of each local model.

Assign an owner for each item so that access requests do not stall the scan.

Can our own team scan Hugging Face models without a partner?

Yes, a single model on one generator is a reasonable task for an engineer who is comfortable with Python and command-line tools. The difficulty grows with the number of targets, because each model may use a different generator, token, license and disk footprint. Governance and evidence add further work: you need consistent configurations, stored reports, and a record of who approved each model and access path. garak writes a JSONL report and a garak.log file for each run, and those files must be kept and compared over time to be useful to an auditor. Decide early whether your team will own that process long term.

Should we scan a model locally or through an Inference Endpoint?

Choose the local transformers pipeline when you control the host, can hold the model on disk and in memory, and want the model weights to stay inside your infrastructure. Choose the Inference API or a private Inference Endpoint when the model is too large for your hardware or when the provider already hosts the model you must test. garak selects these paths with --target_type huggingface for local pipelines and huggingface.InferenceAPI or huggingface.InferenceEndpoint for hosted access. The endpoint path adds hosting charges and depends on network reachability, while the local path adds disk and memory needs on your side.

What does a DeployOpen engagement scope in writing?

DeployOpen works from a fixed scope that is agreed in writing before work starts. For a Hugging Face scan, that scope normally names the models and target types in use, the token and license handling responsibilities, the hosts and network paths involved, the disk and memory checks, the probes and generations to run, and the form of the reports you receive. It also states which steps are DeployOpen's and which remain with your team. Ongoing scheduled rescans or upgrades can be added as a retainer. DeployOpen does not publish a price list, so ask for a quote that follows from that written scope.

Does scanning gated Hugging Face models create extra compliance risk?

It can, because gated models carry license terms that your legal or procurement team must accept, and the token that grants access is a credential that needs protection. Confirm who accepted the license for each gated model and keep that record with the scan evidence. Store the read-role token in your approved secrets system rather than in scripts or shell history, and rotate it when people change roles. These steps do not certify anything on their own, but they give compliance reviewers a clear account of access and licensing. Independent auditors and certification bodies make the final assessment of your controls.

How DeployOpen scopes and delivers garak scans on Hugging Face targets

DeployOpen plans and runs garak scans against Hugging Face targets inside your own infrastructure, starting from a written scope that names the generator, the model or endpoint, the probes and the evidence you need. The work covers token handling, gated model access, disk and memory planning and a documented run you can repeat.

How we scope

  • Engagements are fixed-scope, with the target type, model or endpoint and probe set agreed in writing before work starts
  • We confirm whether the target is a local transformers pipeline, an Inference API model or a private Inference Endpoint
  • We check gated model access, license acceptance and which account holds the read token used for the scan
  • We size disk and memory for the dependency install and any model run locally on the host you name

How we build

  • We install garak with pip on a Python 3.11 or newer environment in your infrastructure and pin the version used for the run
  • We configure the Hugging Face generator you chose and store HF_INFERENCE_TOKEN in your existing secrets store, not in scan files
  • We run a first scan on a small probe set to confirm the target responds, then expand to the agreed probes
  • We record the exact garak version, generator settings and model revision so the scan can be reproduced later

How we hand over

  • You receive the JSONL report, the garak.log file and a written account of each probe family tested and the failure rates
  • The document covers the generator choice, token and license setup, hardware used and known limits of the scan
  • We walk your security and platform teams through the results and explain how to read FAIL outcomes for each probe
  • Scan settings are delivered as a versioned config so your team can rerun the same test on a new model revision

How we support

  • Ongoing rescans, garak upgrades and continuous testing are available as a retainer after the initial engagement
  • We can help rotate read tokens, refresh gated model access and update the scan when a model or endpoint changes
  • Retesting after fixes is included in the written scope where agreed, so you can confirm changes took effect
  • Ask us to confirm which garak release and Hugging Face generator the retainer will cover before signing

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.