Estimating the API cost of a garak scan

Learn how garak request counts, generations and character volume drive model API or GPU spend, how to measure a finished run with count_tokens, and how to trim cost while keeping the coverage you need.

On this page

Estimating the API cost of a garak scan before you run it

Cost for a garak scan follows from three things: the number of requests, the number of generations per prompt, and the size of each prompt and response. garak does not bill anything itself. It is free and licensed under Apache 2.0, so every dollar of spend comes from the model provider you call or from the GPU hardware under test. A team asking for budget approval should therefore estimate the requests the probe selection will send, multiply by the generations setting, and price that volume against the provider's published rates or the cost of the hardware hours. The estimate is needed before approval, again when a rescan cadence is set, and after each run to attribute the spend to a specific test.

Request count is the largest driver. The default configuration makes 5 generations per prompt, so changing the generations setting or narrowing the probe list changes the bill more than most other choices. Start by listing the probes and their prompt counts for the run, then decide whether a reduced probe set or a prompt cap covers the risks you need to test. Confirm with your provider whether the rate applies per request, per input token, per output token, or per GPU hour, because a rate in one unit cannot be compared with another without converting the character counts into the unit the provider bills. Also confirm whether your account has a rate limit or spend cap that could stop a run partway through.

After a run, the count_tokens tool in the garak analyze package counts the characters sent and received, based on prompts, outputs and generations, and it is the most direct way to turn a finished report into spend. Use those figures with the provider's pricing to produce a cost per probe family or per target, which supports both chargeback and decisions about which probes to keep on a recurring schedule. Ask your provider or platform team for the exact billing unit, any free allowance, and the discount structure for committed use before you finalize the budget, since those terms, not garak, set the final amount.

Measuring a garak run with count_tokens

This sequence turns a finished or sampled garak run into a measured count of characters sent and received, which you can convert into provider tokens or GPU time using your own rates. The result is a number grounded in your actual report rather than an estimate from probe counts alone.

  1. Finish or sample the scan run

    Decide whether to measure a complete run or a sample, such as a single probe family with a reduced generation count. Run garak with the configuration you plan to repeat, so the measured traffic matches the traffic you will budget for. The step is complete when garak exits and reports a summary for every probe it executed, or when the sampled run has finished without errors.

  2. Locate the JSONL report and garak.log

    Find the JSONL report that garak wrote for this run, which records each attempt and its evaluation, along with the garak.log file that is continued across runs. Confirm the report filename matches the run you just completed, because older reports in the same directory can be picked up by mistake. The step is complete when you have the exact report path and can open the file and see entries for the run.

  3. Confirm the report covers intended probes

    Before counting anything, check that the report contains attempts for every probe family you meant to include in the budget. Compare the probes listed in the report against your planned probe selection, and note any probe that is missing or that ran fewer attempts than expected. The step is complete when you have a short list of probes that match your plan, and any gaps are either fixed by rerunning or recorded as excluded from the estimate.

  4. Run the count_tokens analysis tool

    Run the count_tokens tool from garak.analyze against the report path you confirmed. The tool counts the characters sent and received in the report, based on the prompts, outputs and generations it contains. The step is complete when the tool prints character totals for the run without raising errors about the report format.

  5. Read the sent and received totals

    Record the character count for prompts sent to the target and the character count for outputs returned, keeping the two figures separate. Note the probe and generation settings used, so the totals can be tied back to a repeatable configuration. The step is complete when you have one sent figure and one received figure for the run, with the settings written beside them.

  6. Confirm which side your provider bills

    Check your provider's pricing terms to see whether it bills input characters or tokens, output tokens, or both, and whether it applies a different rate to each. Some hosted endpoints also bill for system prompts or cached context that the report does not show directly, so confirm this with the provider. The step is complete when you have written down which side of the count is billed and at what rate, and what the provider does not bill.

  7. Convert characters to tokens or GPU time

    Convert the character totals into provider tokens using the tokenizer ratio or the provider's documented conversion, then apply the provider's own rates for input and output. For a self-hosted model, convert the measured traffic into GPU time using your observed throughput on the hardware you control. The step is complete when you have a cost or GPU-hour figure for the run, with the conversion assumptions stated so another reviewer can repeat the calculation.

How hosted APIs and local GPUs price the same scan differently

Hosted endpoints bill for usage, so the cost of a garak run follows the number of requests and the size of the text sent and returned. garak's count_tokens tool totals the characters sent and received in a report, which gives you the raw input for a usage estimate. Provider invoices usually use their own billing units, so you must convert characters into those units before you forecast spend.

  • One-time setup: account creation, API key provisioning, and a project budget or spend limit set before the first scan.
  • Recurring run cost: every attempt is billed, and the default of 5 generations per prompt multiplies the request count for each probe that runs.
  • Rate limits stretch time: requests per minute caps lengthen wall-clock time without raising the bill, which affects how long the scan occupies your schedule.
  • Failed and retried calls: rate-limited or timed-out requests may or may not be billed, depending on the provider.
  • Ask the provider for: the price per input and output unit for the model under test, any batch or volume tiers, rate limits per key and per model, and a written statement on billing for failed requests.

Confirm whether the provider bills input and output separately, because the sent and received character totals map to different line items on the invoice.

Levers that change scan spend and what each costs in coverage

This table compares the settings that change how many requests and characters a garak scan sends, and what each setting gives up in coverage. Read each row as a trade: the saving on the left, the loss of confidence or breadth on the right. Most teams get the largest saving from probe selection and generation count, and should confirm the trade-offs against their own report before cutting either.

LeverWhen it fitsCoverage trade-off
Probe selection by spec or tagKnown exposure, such as a chatbot with no tools or no retrieval, so some probe families are not relevantUntested families may hide weaknesses; confirm the excluded probes match your threat model before the run
Generations per promptRepeat checks where you need a fast signal on a stable modelFewer generations lower confidence in the failure rate, because a single bad output in five attempts is harder to miss than in one
Prompt capLarge probe sets where a sample of prompts per probe is enough to see whether a behavior changedRare failures may fall outside the sampled prompts, so a clean capped run is weaker evidence than a full one
Parallel attemptsHosted endpoints with spare rate limit, where wall-clock time matters more than request countDoes not reduce total requests or token spend; it can raise load on the endpoint owner's side, so agree rates first
Scheduled versus full runsScheduled regression checks after a model, prompt or guardrail changeScheduled runs compare against a narrower baseline; run a full scan before a release or audit
Fast config for repeat checksRoutine checks in a pipeline or after small configuration changesCovers a subset of probes at low generation counts, so it signals change, not overall posture
Character volume from long outputsTargets that return long answers, where a smaller output limit can cut returned charactersTruncated outputs can hide unsafe content late in a response; check the detector still sees the full text

Cutting spend without losing coverage

A garak scan spends money on every request, so the cheapest run is rarely the best one. The tactics below separate the checks you run on every change from the full sweep you reserve for decisions, and each one names the coverage it could quietly give up.

Tier probes by purpose

Split your probe selection into a small set that runs on every change and a broad set that runs on a schedule. The coverage risk is that the small set misses the probe family where a regression appears, so the quick tier can look green while a weakness goes untested. To check it, compare the failing probes in past full runs against the quick set and confirm each family that has ever failed is represented.

Keep generations where failures show

garak makes 5 generations per prompt by default and marks a probe as FAIL when any attempt produces undesirable output. Lowering generations cuts requests roughly in proportion, but a weakness that appears in only one attempt in five can disappear. Reduce generations only on tiers where you read the failure rate as a trend, and confirm that the reduced run still reproduces a known failure before you trust it.

Skip reruns of unchanged configurations

If the model, system prompt, generator settings, garak version and probe selection are identical to a previous run, a new scan mostly repeats spend without new information. The coverage risk is that sampling noise makes a repeat look like a change, so teams rerun more often than needed. Record a fingerprint of the configuration with each report and reuse the prior result when the fingerprint matches.

Cap spend with a dedicated key

Give scans their own API key with a spend limit set by the provider, separate from production traffic. This bounds the damage from a misconfigured probe set or a loop that multiplies requests, but a hard cap can stop a scan partway through and leave the report incomplete. Ask the provider how the limit behaves at the cap, and check that the scan records an incomplete run instead of a clean pass.

Reserve full runs for gates

Run the complete probe set only at release gates, model swaps and before a compliance review, and let the tiered quick runs cover the period between them. The coverage risk is a gap of weeks in which a regression goes unseen, so the gate cadence must be set against how often your model, prompts or guardrails change. Confirm the schedule with the owners of each change type and record which full run each release relied on.

How configuration becomes request volume and spend

The diagram starts with the run configuration, where probe selection, generations per prompt and any prompt cap set how many attempts garak plans. Those attempts go to the target model or GPU endpoint, which is the boundary where garak's work ends and the provider or infrastructure bill begins. garak then writes the JSONL report and garak.log, and count_tokens totals the characters sent and received from the report, which you multiply by your own provider or hardware rates. Check the planned request count before the run, and check the character totals after it.

Configuration drives planned requests, and spend starts where garak's calls reach the target endpoint.

Questions teams ask before estimating garak scan cost

Does garak itself cost money to run?

No. garak is a free, Apache 2.0 licensed tool, so the license fee is zero. The money you spend goes to whoever serves the model under test: a hosted API billed per request or per token, a cloud GPU billed by the hour, or your own hardware, where the cost is power and capacity. Garak also sends requests on your behalf, so the bill lands on the target's owner, which is why you should agree on the scan budget with that owner before the first run. Confirm the billing terms of your specific provider, since rate cards differ by model and region.

How do I get a rough cost number before the first scan?

Start from the request count, then multiply by your provider's price. Garak's default of 5 generations per prompt means every prompt you select can produce up to five attempts, so the count grows with the number of probes, the prompts each probe sends and the generations setting. Run a small probe subset first, read the report, and extrapolate to the full list. Your rate card from the provider then converts requests into money. Ask the provider whether input and output tokens are billed separately, because the answer changes the calculation.

Why does count_tokens report characters instead of tokens?

The garak.analyze.count_tokens tool counts the characters sent and received in a report, based on prompts, outputs and generations. It does not run your model's tokenizer, so it cannot give billable tokens directly. Providers bill tokens, and the character-to-token ratio varies by model and language. Use the character totals as a relative measure for comparing probe sets and runs, then convert with a sample of your own model's tokenizer or the usage numbers your provider returns. Treat any conversion as an estimate until you have checked it against a real invoice.

How long does estimating scan cost take, and what must we provide?

The estimate itself is a small piece of work, and its length depends on how many probe families, endpoints and models are in scope. The inputs that matter most are the probe list or the scan goal, access to the target endpoint or a test deployment, and the current rate card for every paid service in the path, including any guardrail or judge model that adds calls. Confirm the timeline and scope in writing before work starts, since DeployOpen agrees fixed scope and deliverables up front.

Can our own team estimate garak scan cost in-house?

Yes, if you have an engineer who can read garak's reports and your provider's billing data. The core steps are to pick the probes, count requests from a dry run or a small pilot, measure characters with count_tokens, and apply your rates. Teams usually struggle with three things: confirming which calls the target and any judge models make, separating generation cost from evaluation cost, and keeping the numbers current when the probe set or garak release changes. The garak documentation at docs.garak.ai covers the report formats you will need.

How do we avoid surprise bills from repeated rescans?

Set a budget per scan in requests and currency before each run, and set a hard spending limit with the provider where it offers one. Cap generations and prompts for scheduled runs, keep a fixed short probe set for frequent checks, and reserve the full probe list for release or model changes. Log the request and character totals from each report so you can compare runs over time. Recurring cost comes from the schedule, not the tool, so the rescan frequency is the lever you control. Confirm the provider's alerting and quota options before you automate anything.

What does a DeployOpen quote depend on?

A quote follows from the written scope. DeployOpen does not publish a price list, so the quote depends on which endpoints and models are tested, which probe families and generation settings are agreed, whether the work is a one-time estimate or a recurring scan programme, and how much of your billing data the team must review. Ask for the scope, deliverables, timeline and the assumptions behind any cost figure, and check that the quote lists which provider charges are passed through to you and which are included.

Security and billing controls around a scan

A garak scan that calls a paid model API spends money and writes prompts and model outputs to disk. The controls below connect the cost estimate to who can launch the run, which key pays for it, where the report goes and who approves the spend before the first request is sent.

Scope a dedicated API key

Run estimation scans with a separate, low-limit API key rather than a key shared with production traffic. Set a spending cap or budget on that key at the provider and rotate it on a schedule. Keep the key in your secrets manager or CI secret store, not in a garak configuration file committed to a repository. Check that the key cannot reach models or billing scopes the scan does not need, because a leaked key with broad scope turns a cost estimate into an open account.

Limit who can launch paid scans

Each scan that calls a hosted endpoint spends money on every request, so restrict launch rights to named scan owners. Use your CI platform's protected environments or approval gates for jobs that use the paid key, and keep ad hoc laptop runs on a sandbox key with a lower cap. Record who started each run and which probe set it used, so the spend can be traced back to a decision.

Keep harmful output out of cost dashboards

Cost dashboards and billing exports are shared widely, but garak reports contain the attack prompts and the model outputs that resulted from them. Send only counts, character totals and run identifiers to shared dashboards, and keep the JSONL report and garak.log in a restricted location. Confirm that your observability tools do not capture the console output of scan jobs, since verbose logging can copy prompt text into a log index.

Derive character totals from reports

Use the count_tokens tool on the finished report to get the characters sent and received, then share only those totals. This gives finance a figure to match against the provider invoice without exposing report content. Compare the character totals with the provider's billed units for the same run, and note any gap, since differences usually come from retries, system prompts or tokenization rules.

count_tokens source

Approve spend against the scan plan

Before the run starts, the scan owner should present the planned request count, the probe list and the spend ceiling to the budget approver. Agree who can raise the ceiling mid-run and what happens when a run hits the limit, such as stopping the scan and keeping the partial report. Tie approval to the written scope so that a change in probes or generations triggers a new approval instead of silent overspend.

Stop runs that exceed limits

Set a hard stop on runs that go beyond the approved request count, using provider-side limits as the backstop and a monitored wall-clock timeout in the scheduler as the second layer. Confirm with the endpoint owner how their rate limits and billing alerts respond to a sudden burst, because a stopped job can still leave a large bill from requests already accepted. Review the partial report to decide whether to rerun or accept the coverage gained.

How DeployOpen scopes garak cost work

DeployOpen scopes garak cost work as a fixed-scope engagement, so the estimate comes from a written list of what will be measured before any scan runs. That scope names the probe families and tags in use, the generators and endpoints under test, the generations per prompt, the models that will act as detectors or evaluators, and the rerun cadence. Each of these maps directly to request counts and character volume, so a quote can be traced back to the scope line that drives it. Where a target is a hosted API, the scope also records who holds the billing account, because that decides who pays for the requests and who sees the invoice.

The quote follows from that scope rather than from a template. It covers the work DeployOpen performs: planning the probe selection, running a baseline scan, using the count_tokens analysis on the resulting report to measure characters sent and received, reviewing where spend concentrates, and documenting the settings that keep coverage while trimming volume. Ask for the quote to separate the one-time setup and baseline from any recurring work, and to state which costs stay with your team, such as the model provider invoice or GPU hours on your own hardware. Confirm with us how the scope will be revised if probe selection or the endpoint changes mid-engagement.

Optional retainers cover scheduled scans once the baseline is settled. A retainer can keep a defined probe set running on a set cadence, re-check character volume after model or prompt changes, and flag when a garak release shifts the request count for the same configuration. Before agreeing a retainer, confirm the rerun cadence, the endpoints in scope, and who approves a change that would raise spend. Those three points are what turn a one-time estimate into a predictable monthly cost.

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.