Testing models behind a LiteLLM proxy with garak

Point garak's LiteLLM generator at the models your LiteLLM proxy routes, with provider keys kept in the environment and generation settings fixed in config. Scope it before the first scan.

On this page

Testing models behind a LiteLLM proxy with garak: what the integration does

If your models sit behind a LiteLLM gateway, the scan you need tests what users actually reach, not only the upstream provider. garak's LiteLLM generator covers that case. It calls LLM APIs in the OpenAI request format through LiteLLM, and LiteLLM reads each provider's API key from the matching environment variable, such as OPENAI_API_KEY. The generator is the supported entry point for models routed through LiteLLM, and garak's README lists LiteLLM among its supported targets alongside Hugging Face, Replicate, OpenAI, AWS Bedrock and gguf models. You can confirm the current generator options in the garak source for the LiteLLM generator before you write your scan configuration.

LiteLLM is two things, and the distinction changes what you test. It is a Python SDK that your scanning host can import, and it is an AI gateway (proxy server) that exposes one OpenAI-style endpoint in front of more than 100 providers. A self-hosted proxy is the case most organizations mean when they say their models sit behind LiteLLM, because the proxy adds virtual keys, routing, budgets and any guardrails your team configured. Those controls are part of the system under test. The generator's direct call path reaches the models through LiteLLM's routing layer, but it does not by itself test the access rules, team-level settings or logging that your proxy enforces. Confirm with your platform team which proxy configuration is live, and decide whether the scan should use a virtual key with the same model restrictions as a real user.

This integration does not cover the proxy's own security. A garak scan measures how the model and gateway respond to adversarial prompts. It does not test authentication to the proxy admin UI, SSO configuration, network exposure, secret storage for LITELLM_MASTER_KEY, or database and Redis hardening, and it does not produce a compliance attestation. Those need a separate review of your LiteLLM deployment. Also confirm which garak version you run, since the current release, v0.17.1, was published on 16 October 2026, and check the LiteLLM release you deploy against its releases page.

What you need before a LiteLLM proxy scan

A LiteLLM proxy scan depends on four layers working together: the garak install on the scan host, the LiteLLM proxy version and its routes, the provider keys behind it, and the database services that only matter once the proxy runs several instances. Check each layer before the first probe so that failures show up as configuration problems, not as misleading test results.

Python runtime for garak

The garak package on PyPI requires Python 3.11 or newer, and garak is developed on Linux and macOS. Install it on the scan host from PyPI into a virtual environment and confirm the interpreter version before anything else. Record the garak version in your scan notes, since the v0.17.1 release dated 16 October 2026 changed scoring behavior that affects comparisons with older runs.

garak on PyPI

Pinned LiteLLM proxy version

Confirm which LiteLLM version your proxy runs and pin it. The LiteLLM releases page lists v1.105.1, published October 14, 2026, but your proxy may run a different release. LiteLLM supports the four most recent stable minor versions, so an older proxy may need an upgrade before your security team signs off on the test target. Ask the platform owner for the exact image tag or package version.

LiteLLM releases

Provider accounts and API keys

The garak LiteLLM generator reads provider keys from the environment variables that LiteLLM expects, such as OPENAI_API_KEY. Decide whether the scan uses the proxy's own key or a separate key, and confirm which provider accounts sit behind each model alias. Keep keys in your secret manager and export them only in the scan shell, so they never appear in shell history, config files or the JSONL report.

garak LiteLLM generator

Network route to the proxy

The scan host must reach the proxy endpoint over the port and path your platform team publishes. Check DNS resolution, TLS trust for any internal certificate authority, and whether an ingress, IP allowlist or VPN sits in front of the proxy. A scan that cannot connect often fails late in the run, so run a single test request with your intended model name before starting a full scan.

Database and cache for shared proxies

Single-instance testing against a proxy may not need extra services, but virtual keys require PostgreSQL. LiteLLM names PostgreSQL as the primary supported database and requires Redis 7.0 or newer once more than one proxy instance runs, for shared rate limits, router state and cache. If your scan uses per-team virtual keys or budgets across several instances, confirm both services exist, are backed up and are monitored before the test.

LiteLLM virtual keys

How to configure the LiteLLM generator step by step

This sequence connects garak to a LiteLLM proxy in a controlled order, so each layer is confirmed before the next one is added. The result is a repeatable scan setup with a verified endpoint, a documented configuration and a first report.

  1. Install garak from PyPI

    The security engineer installs garak with pip into a dedicated virtual environment on Python 3.11 or newer, since the PyPI package requires that version. Record the installed version in your scan log so later reports can be compared against the release used. Done when the garak help output prints without import errors and the version matches the release you intend to use.

  2. Confirm the proxy answers an OpenAI-format request

    Before involving garak, send one chat completion request to your LiteLLM proxy using the OpenAI request format, with a model alias the proxy has been configured to serve. Use a key the proxy issued for testing, not an administrator key. Done when the proxy returns a normal completion for that alias, which shows routing and authentication work independently of garak.

  3. Set provider keys as environment variables

    Export the provider credentials as environment variables in the shell or job that runs garak, using the names LiteLLM reads for each provider, such as OPENAI_API_KEY for OpenAI. Keep these values out of configuration files that enter version control. Done when the variables are visible in the same session, and a short test call through the generator succeeds without a key being typed on the command line.

  4. Select the LiteLLM generator and model name

    Point garak at the LiteLLM generator and give it the model name that matches the target the proxy exposes. Confirm the exact option names against the current garak user guide for your release, since names can change between versions. Done when garak starts, reads the model setting and reports the LiteLLM generator as the target in its startup output.

  5. Set generation parameters in a config file

    Write the generation settings, such as temperature, maximum tokens and any system prompt, into a version-controlled garak configuration file, so the same settings apply on every rerun. Record any default parameters the proxy or the underlying provider applies, because they affect results. Done when a run started from the config file logs the parameters it loaded, and those values match what you wrote.

  6. Run a small probe to confirm the setup

    Run one narrow probe family against the proxy with a small number of prompts, so any failure is quick to diagnose. Watch the terminal for authentication, model-not-found or rate-limit errors that originate at the proxy. Done when the run completes and writes a JSONL report containing an entry for each attempt, and garak.log shows no unexpected errors.

  7. Scale to the full probe set

    After the small run is clean, widen the probe selection to the set your threat model requires and keep the same configuration file. Watch proxy-side rate limits and budgets, because a larger run sends many more requests through the same keys. Done when the full run finishes, the report and log are saved with the garak version and config file recorded alongside them.

How garak's requests reach provider models through the proxy

The diagram starts on the scan host, where garak runs its probes through the LiteLLM generator and writes the JSONL report and garak.log. Requests cross into the self-hosted LiteLLM proxy, which holds the provider API keys and applies default generation parameters before forwarding each call to an external provider. Check where the keys live, which side of the trust boundary the proxy sits on, and whether the report and log contain any prompt or response content you must protect.

Requests flow from garak through the LiteLLM proxy to an external provider, with results stored on the scan host.

Where provider API keys live in a proxied scan

In this option, garak's LiteLLM generator calls the provider directly, and LiteLLM reads the provider key from the matching environment variable on the machine running the scan, such as OPENAI_API_KEY. Nothing sits between the scanner and the provider, so setup is quick and there is no proxy to operate. The cost is that every scan host holds raw provider credentials.

  • Rotation: Each host must be updated when a provider key changes, and a missed host keeps working with the old key until someone notices.
  • Audit: Provider logs show the key, not the person or job that used it, so attribution depends on your own run records.
  • Blast radius: A compromised scan host exposes the full provider key, with whatever quota and model access that key carries.
  • Shell history and CI logs: Exporting keys in shells or pipelines is a common leak path, so confirm your runners mask secrets.
  • Fit: This suits a single analyst running occasional scans against a non-production key.

Before choosing this option, confirm with your security team whether scan hosts are allowed to hold provider credentials at all.

How default generation parameters affect scan results

Generation settings are part of the scan result, not background configuration. garak makes 5 generations per prompt by default and marks a probe as FAIL when any attempt produces undesirable output. The failure rate therefore depends on how many attempts run and how much the model varies between them. Raising the generation count gives a weak behavior more chances to appear, so a model can score differently in two runs that differ only in that number. Temperature changes the variation between attempts, and a maximum output length can cut off a response before a leaked string or unsafe instruction appears. Each of these moves the result without changing the model.

Pin these values in a garak configuration file that lives under version control, and keep the LiteLLM route, the model name, the generation count, temperature and maximum output length in the same file. Use the same file for every rerun you plan to compare, and store it next to the JSONL report and the garak.log file from that run. When a score moves, you can then tell whether the model, the proxy routing or a setting changed. Treat any change to these values as a new baseline, not as a continuation of the old series.

Before you rely on any parameter, confirm which settings the LiteLLM generator forwards to the proxy. Read the generator source in garak's litellm.py and check the keys it passes in the OpenAI-format request. Then run one short probe and inspect the proxy logs to see what arrived. The proxy may also apply defaults or overrides for a model or virtual key, so the value in your scan file may not be the value the provider receives. Record that confirmed behavior with the baseline, because it decides whether your scan settings mean what you think they mean.

Mapping proxy model names, keys and routes to garak settings

This table maps each identifier in a LiteLLM-fronted scan to the garak setting that consumes it, so a wrong name fails early rather than silently testing the wrong model. Read each row from the LiteLLM proxy outward: the name clients request, the key that authorizes the request, and the environment variables and files that garak and its output depend on.

ElementWhere it is setWhat garak uses it forOutput or check
LiteLLM model namemodel_name entry in the proxy configurationValue garak passes as the model name so the proxy routes the request to the intended deployment. Confirm the exact string with the proxy's model list before the first scan.Compare with the model list the proxy returns; a mismatch usually produces request errors, not a valid scan
garak generator and model namegarak command line or config file for the litellm generatorSelects the LiteLLM generator and sets the model name it sends. Keep it identical to the proxy's model name, since garak does not map one to the other.Recorded in the run's report metadata and the garak.log entries for that run
Provider environment variableEnvironment of the scan host or the proxy, such as OPENAI_API_KEYRead by LiteLLM to authenticate to the upstream provider. Set it where the LiteLLM call is made; a direct proxy setup means the provider key stays on the proxy host.Check with a single test request; never write the value into config files or reports
Virtual key or master keyProxy secret store, passed by the scan host as the API keyAuthenticates the scan host to the proxy. A virtual key limits the scan to approved models and budgets; the master key grants full administrative access and should not be used for routine scans.Confirm the key is restricted to the scanned model; LITELLM_MASTER_KEY must start with sk-
Route from scan host to proxyBase URL setting for the generator, pointing at the proxy addressSets the network path garak uses. Scans from a host on a different network need firewall rules and TLS trust for the proxy endpoint.Confirm the route with a request from the scan host before running the full probe set
Upstream route inside the proxyDeployment list and router settings in the proxyDecides which provider deployment answers a given model name. Failover or load balancing can send attempts to different providers, which changes what the scan actually tested.Record the deployment used in proxy logs and keep the route fixed for comparable runs
JSONL reportWritten by each garak run to its report directoryHolds every attempt and its evaluation for the model name and generator used in that run. Store it with the proxy model name and key identifier so results trace back to the right route.Check the model name field in the report matches the proxy name
garak.log fileWritten by garak and continued across runsDebugging record of connection, authentication and generator errors. Failed proxy calls show here first, so review it when a run reports unexpected failures.Search for authentication and connection errors before reading any scores

Securing the scan path and the proxy

A garak scan through LiteLLM touches three sensitive things: provider keys, a proxy that can spend money, and reports that hold every prompt and output. The cards below cover how to keep each one contained, from the shell where the scan starts to the files it leaves behind.

Keep keys out of history and reports

Provider keys reach LiteLLM through the matching environment variables, such as OPENAI_API_KEY, so the scan host needs those variables and nothing else. Export them from a secret manager or a protected file rather than typing them inline, because inline exports end up in shell history and process listings. Before you share a run directory, check that no configuration file or log copied a key into it. Confirm which values your garak version writes to garak.log.

garak LiteLLM generator

Restrict virtual keys to models under test

Create a dedicated LiteLLM virtual key for each scan, and limit it to the models the scan is meant to exercise. A key that can reach every provider turns a scanner misconfiguration into access to production models. Ask whether the key scope also covers the model aliases your garak configuration names, because a mismatch can cause failed attempts that look like model behavior. Virtual keys require a PostgreSQL database.

LiteLLM virtual keys docs

Cap spend with budgets and rate limits

A garak run sends many prompts, and each generation is billed by the provider. Set a per-key budget, plus TPM and RPM limits, before the first run so a misconfigured probe set cannot exhaust the account. Temporary budget increases can be granted for a planned larger run and then removed. Ask your team to estimate attempts per run from the probes selected, then size the budget against that count.

Allowlist network paths to the proxy

Limit the scan host to the proxy address and port, and keep the proxy's own outbound path to provider APIs under your control. Where the proxy runs in a cluster, expose it on an internal service and avoid a public ingress for scan traffic. Confirm that the scan host cannot reach model providers directly if the policy requires every call to pass through the gateway. Document the allowed paths so reviewers can test them.

Treat JSONL reports as sensitive data

Each garak run writes a JSONL report of every attempt and its evaluation, and those records contain the prompts sent and the outputs returned. Some probes carry sensitive or harmful content by design, and a report can also echo private data from your application. Store run directories in an access-controlled location, set a retention period agreed with your data owner, and redact before sharing outside the security team.

Control admin access and audit trails

Protect the proxy admin UI with SSO. From v1.76.0, LiteLLM SSO with Google, Microsoft Entra ID, Okta or generic OIDC is free for up to 5 users, and an Enterprise license is needed beyond that. Audit logs, organization and team RBAC, and secret manager integrations (AWS, Azure, Google, HashiCorp Vault, CyberArk) are Enterprise features, so confirm whether your rollout needs them before you rely on them for evidence.

LiteLLM admin UI SSO

Common failures when scanning through LiteLLM

This table lists the failures teams most often hit when garak scans models through a LiteLLM proxy, with the likely cause and fix for each. Work down the rows in order, since a missing provider key or wrong model name stops a run before any budget or rate limit matters. The main takeaway is that most failures trace to configuration on either the garak side or the proxy side, and the garak.log file usually shows which.

FailureLikely causeFix
Provider authentication errors on the first attemptThe provider API key is not set in the environment where garak runs, or the variable name does not match what LiteLLM expects for that provider, such as OPENAI_API_KEY for OpenAI models.Export the matching variable in the shell or job that runs garak, then confirm it is visible to that process. Check garak.log for the authentication error text before changing anything else.
Model not found or unknown modelThe model name passed to garak does not match a model name defined in the proxy's configuration, or garak is calling the provider directly instead of the proxy.Compare the name garak sends with the model_name entries in the proxy config and with the list the proxy reports. Use the same name on both sides.
Requests rejected with a key lacking model accessThe virtual key used for the scan is restricted to a set of models that does not include the target model.Check the key's allowed models in the proxy admin, add the target model or issue a scan-specific key that covers it, then rerun.
Attempts stop with budget or rate limit errorsThe virtual key or team has a spend budget, TPM or RPM limit that a full probe run exceeds. Each probe sends several generations per prompt by default, so usage climbs quickly.Review the key's budget and limits before the run, raise them for the scan window or use a dedicated scan key with agreed limits, and consider a smaller probe set for the first pass. Check garak.log for 429 or budget messages.
Intermittent failures or inconsistent results across a multi-instance proxySeveral proxy instances run without Redis, so shared rate limits, router state and cache are not coordinated between them. LiteLLM's production guide requires Redis 7.0 or newer once more than one instance runs.Deploy Redis 7.0 or newer for the proxy cluster, confirm all instances point to it, and rerun a short probe to confirm stable behavior before a full scan.
Proxy returns errors that differ from the provider's ownA router cooldown, retry or failover setting in the proxy is hiding or rerouting failing deployments, so garak sees a generic error.Check the proxy logs for the underlying provider error and review the routing and cooldown settings for the model group under test.
Unexpected output parameters or changed behaviorDefault generation parameters set in the proxy or in garak's generator config override or conflict with each other, so the model is not tested as its owner expects.Write down the effective temperature, max tokens and other settings on both sides, keep one source of truth, and record them in the scan configuration so the run is repeatable.
Scan results missing or incomplete after a crashThe run stopped partway, and the report only covers the attempts completed before the failure.Locate the JSONL report and garak.log for the run, identify the last successful attempt in the log, and rerun the affected probes with the same configuration.

Questions buyers ask about scanning LiteLLM-routed models

Does garak cost anything to run against a LiteLLM proxy?

garak is a free tool, and the maintainers describe it that way in the project README, so the software itself carries no license fee. It is licensed under Apache 2.0. The costs that matter are the ones around it: the compute that runs the scan, the model provider charges for every generation, and the staff time to configure, review and act on results. garak makes 5 generations per prompt by default, so provider token spend scales with the number of probes and generations you select. Ask your provider for the per-token rates on the models behind the proxy, and estimate scan volume from the probe list you choose before the first run. Confirm the current terms with the maintainers at the project repository if your procurement team needs written statements.

How long does a LiteLLM-routed garak scan take to set up?

The duration depends on how many models sit behind the proxy, how many probes you run, and whether the proxy already has working virtual keys and model names. A single model with a known key can be connected in a short session once garak is installed from PyPI, which requires Python 3.11 or newer. Multi-model or multi-team setups take longer because each route needs a verified model name, a key scope and a test call. Scan run time then depends on provider rate limits and the number of attempts. No supplied figure gives a fixed duration, so ask for a written scope with the probe list, model count and environments named before agreeing on a timeline.

What does the client need to provide before a LiteLLM scan?

The client needs to supply a working LiteLLM proxy or the provider keys behind it, a test environment where scans may generate load, and a named owner who can approve which models and probes are in scope. garak's LiteLLM generator reads provider API keys from the matching environment variables, such as OPENAI_API_KEY, so the scanning host needs those variables set securely. Teams should also decide which proxy key garak will use, since LiteLLM virtual keys can restrict a key to specific models and carry budgets and rate limits. A dedicated scan key with a spending cap is a common control. Confirm with your security team where keys are stored and who can read the scanning host.

Can our own team run garak against LiteLLM without a partner?

Yes, a team with Python experience, access to the proxy and authority over the scanning host can run garak alone, because the tool is a command-line application with a published user guide at docs.garak.ai. The work your team must own includes choosing probes, setting generation parameters, interpreting the JSONL report and the garak.log file, and deciding what counts as a failure for your use case. Teams often bring in a partner when they need consistent scan configuration across several models, evidence for a compliance review, or remediation planning after findings. Whichever path you take, record who owns the scan schedule and the report archive.

Is LiteLLM open source, and do we need its Enterprise edition?

LiteLLM is dual licensed. Content under its enterprise/ directory uses the license in enterprise/LICENSE, and everything else is under the MIT license, according to the BerriAI/litellm LICENSE file. A self-hosted proxy without Enterprise features can be run under MIT for the core. The Enterprise edition adds SSO and SCIM beyond the free limit, JWT authentication, audit logs, organization and team RBAC, IP allowlisting and secret manager integrations. From v1.76.0, SSO is free for up to 5 users, and an Enterprise license is needed beyond that. Whether you need Enterprise depends on your identity and audit requirements, not on garak, which the scan itself does not require. Confirm current terms with LiteLLM before committing.

Which parts of a LiteLLM setup change the garak results?

Several proxy settings change what garak sees, so they should be fixed and recorded before scanning. The router strategy matters: LiteLLM supports simple-shuffle (recommended), usage-based, latency-based, least-busy and cost-based routing, plus retries, cooldowns and priority failover. A failover to a different model mid-scan can make results hard to attribute. Default generation parameters set in the proxy or in garak also shape outputs, so record temperature, token limits and system prompts in your scan configuration. Check that the model name garak sends maps to the intended deployment, and confirm with your LiteLLM administrator how routing and fallbacks are configured for that name.

Where do scan results and logs go, and who should see them?

Each garak run writes a JSONL report of every attempt and its evaluation, and a garak.log debugging file that continues across runs. Those files can contain prompts, model outputs and, if misconfigured, fragments of request data, so treat them as sensitive. Store reports in a location your security team controls, restrict read access to the people who need the findings, and apply your retention rules. Ask whether the proxy's own logging also captures prompts, since LiteLLM logging and any team-level logging settings determine a second copy of the same data. Confirm both storage paths before the first run.

Does garak need a database or Redis to test a proxy?

garak itself does not require a database to run a scan. The LiteLLM proxy you test against may need one, and that is a question for the proxy owner, not the scanner. LiteLLM's production guide names PostgreSQL as the primary supported database, needed for virtual keys, and requires Redis 7.0 or newer once more than one proxy instance runs, for shared rate limits, router state and cache. These services affect how the proxy behaves under scan load, including rate limit hits that appear as failed generations. Ask the proxy team to confirm their rate limits and cooldown settings before scanning, so that errors are not mistaken for model weaknesses.

How DeployOpen scopes and delivers a LiteLLM proxy scan

DeployOpen approaches testing models behind a LiteLLM proxy with garak as a fixed-scope engagement that starts with your gateway, provider keys and model routes. We plan the scan around the routes your teams actually use, run it in infrastructure you control, and hand over the configuration, reports and fixes in writing. Ongoing support is available as a retainer.

How we scope

  • Inventory which LiteLLM model names, routes and providers the scan must reach, agreed in writing before work starts.
  • Confirm where garak will run, which provider keys it may hold, and which environment variables carry them.
  • Agree the probe families, generation count and default generation parameters that apply to each target model.
  • Record the deliverables, timeline and acceptance criteria in the written scope, then quote from that scope.

How we build

  • Install garak on a host you control and pin the release version so results stay comparable across runs.
  • Configure the garak LiteLLM generator against your self-hosted proxy, with the proxy base address and model names confirmed.
  • Verify that provider API keys load from environment variables, and that no keys are written into reports or config files.
  • Check that default generation parameters at the proxy match what the scan config records, then run a small trial scan before the full run.

How we hand over

  • Deliver the garak configuration files, run commands and the scan schedule so your team can repeat the scan.
  • Provide the JSONL reports and garak.log output, with a written summary of failing probes and affected model routes.
  • Document how keys, proxy settings and generation defaults were handled, so security and compliance reviewers can check them.
  • Walk your platform and security teams through the results and the fixes proposed for each finding.

How we support

  • Retest affected routes after fixes are applied at the proxy or provider level and record the changed results.
  • Plan repeat scans when you add models, change routing rules or upgrade garak or LiteLLM to a new release.
  • Ongoing support, upgrades and continuous testing are available as a retainer, with terms set in writing.
  • Confirm with your team which LiteLLM edition and features are in use before planning access control or logging reviews.

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.