PromptGuard runs detectors in three tiers: a fast path of in-process regex and heuristic checks that takes single-digit milliseconds, an ML path of transformer classifiers, and a slow path of LLM-judge detectors that are opt-in and bounded by hard timeouts. The fast path ends a scan only when it finds something: a prompt it finds nothing in, which is most benign traffic, goes on to the ML path. This page gives a p99 budget for each detector so you can reason about the tail, and the measurements we have.
The overall target
The number reported asprocessing_time_ms on each event (see the Analytics Cookbook) is engine-only time, it excludes the upstream provider call on the proxy path.
The fast path does not keep the common case to itself. Detectors run in order and the engine stops early only on a detection: a prompt the deterministic layers find nothing in continues to the ML classifiers whenever they are available, and every plan includes them. So on a benign prompt you pay for the ML path. Only the slow path is opt-in: LLM-judge detectors run when a project enables them.
What a detection costs
When a pattern rule blocks a prompt, the proxy, and the Guard API asked for"agreement": false, skip the second opinion. They answer from the fast path, without the ML classifiers, only when nothing those classifiers say could change who decides the block. The classifiers still run in each of these cases:
- An agentic judge is configured, as it is on PromptGuard Cloud and on any install with a judge server: the classifiers’ scores decide whether the judge is asked, and the judge’s block, with its own threat type and rule, then decides in place of the pattern rule’s.
- The project has a policy rule whose action is
allow: its exceptions are judged against the classifiers’ scores. - A classifier made the block, or one of its findings is part of it: then the block is the ML path’s anyway.
Measured on 2026-11-13 on a laptop, classifiers in-process, for “Ignore previous instructions”: with no agentic judge configured, median engine time 1.2 ms with
"agreement": false and 124 ms with true. With a judge configured, as on PromptGuard Cloud, the classifiers run either way, and the two took 41 ms and 45 ms: there the second opinion is what false saves, and on this prompt it is cheap. On PromptGuard Cloud one classifier window takes about 260 ms of one vCPU (below). Production has not been re-measured since this change. Ask for agreement only if you act on the count. Leaving agreement out counts it until 2027-02-11 and stops early after (Guard API).
What we have actually measured
The budgets above are targets. These are the measurements we have, each with its date:
In that production window 83% of scans took over one second, and weekly figures over the ten weeks before it were flat, so it was the steady state rather than an incident. It predates the October 2026 change that moved the classifiers into the API process instead of calling a hosted inference service, and production has not been re-measured since.
Fast path: deterministic detectors
These run in-process on every eligible request, in the order below (the engine short-circuits and returns as soon as a blocking detector fires). No network calls, so latency is CPU-bound and scales with input length.
Fast-path total p99: a few milliseconds for typical prompt sizes. Very large inputs (long documents, tool outputs) push the regex and PII stages higher, budget generously if you scan multi-KB payloads.
ML path: transformer classifiers
The ML path runs the injection classifier (protectai/deberta-v3-base-prompt-injection-v2), the toxicity ensemble (meta-llama/Llama-Prompt-Guard-2-86M, KoalaAI/Text-Moderation, unitary/toxic-bert and cardiffnlp/twitter-roberta-base-hate-latest) and the multi-turn detector’s embedder (sentence-transformers/all-MiniLM-L6-v2). Where they run is set by ML_INFERENCE_MODE, and the same rules apply on PromptGuard Cloud and on a self-hosted install:
In-process, the injection classifier scores one 512-character window in about 260 ms on one Cloud Run vCPU, and a long prompt is scored in windows: a 16-window prompt takes about 2.0 s on the 4 vCPUs PromptGuard Cloud gives the API. Production has not been re-measured since the move (above).
The ML path fails open to regex. If a classifier cannot answer, the request still gets the deterministic verdict: you lose recall, not availability. On a self-hosted install you fetch the weights yourself with your own Hugging Face token and mount them at
LOCAL_INFERENCE_DIR (Third-Party Models); PromptGuard does not ship them.Slow path: LLM-judge detectors
These call a generative LLM to reason about context. Each is opt-in per project or plan tier and guarded by a hard timeout; on timeout the detector falls open and the request proceeds on the fast/ML verdict. Treat the timeout as the p99 ceiling, the budget is “as fast as the model answers, never longer than this.”The per-request ceiling
Every timeout above bounds a call.DETECTION_BUDGET_MS (default 5000) bounds the request.
It exists because long input is split into overlapping windows and each one is classified separately, so a provider that is slow on every chunk multiplies its per-call timeout by the number of windows, up to 16 of them. Bounding one call does not bound what you wait for.
When a scan spends the budget it stops classifying further windows. The leading windows are always classified, so you never lose detection entirely, but the scan did not finish, and PromptGuard does not decide on your behalf what that means:
fail_mode: open: the request is served on the partial verdict, the skip is counted, and the event carriesdetection_incompleteso a provider outage stays distinguishable from a period with no threats.fail_mode: closed: the request is refused with503 detection_unavailable, exactly as it would be for a detector that errored. Content we did not finish evaluating is not forwarded.
detection_incomplete, and fail_mode decides the request.
Raise the budget if you routinely scan multi-KB documents through a high-latency inference endpoint and prefer the wait to the truncation. Lower it if you would rather cap the tail hard and let fail_mode handle the remainder.
Keeping the tail small
- Lean on the cache. Identical inputs reuse the prior verdict in < 0.1 ms. High cache-hit rates are the single biggest lever on p99.
- Only enable the slow path where it earns its keep. LLM-judge detectors are for ambiguous, high-stakes surfaces (agentic tool calls, custom NL policies, RAG grounding), not every endpoint.
- Right-size
ML_INFERENCE_MODE.apifor recall,offfor the lowest, most predictable latency,localfor the classifiers in-process with no call to hosted inference. - Set
fail_modedeliberately.openfavors availability (allow on engine error);closedfavors safety (block on error). Zero-trust projects should runclosedand accept that a slow/unreachable detector then blocks rather than falls open. Set it per project at creation, or later viaPATCH /dashboard/projects/{project_id}/settingswith{"fail_mode": "closed"}; a project that has never set it isopen. - Measure, don’t guess. These are budgets. Read your actual percentiles per detector from the detector latency histogram when you self-host, or from
processing_time_msthrough the Analytics Cookbook on any deployment. An event records the engine’s total time, not each detector’s.
Per-detector latency (self-hosted)
A self-hosted API exports how long each detector takes as the Prometheus histogrampromptguard_detector_latency_seconds, at /metrics (how to reach it). Its one label, detector, takes the values in the detector label column of the tables above, so every row has a series, and its size is fixed by the engine, not by your traffic. Rows that share a value are one series: the regex and ML layers of injection are both injection, for example.
Also exported, with no budget row: gibberish, language, code_vuln.
Each run of a detector adds one observation. A detector that did not run adds none: one skipped because an earlier detector already blocked, one your plan does not include, or everything after the policy cache on a cache hit.
Each detector’s p99 over five minutes:
processing_time_ms instead.
Measuring it yourself
The budgets above are engine-only. What your users feel is engine time plus the network hop to PromptGuard, so measure from the client to get the number that matters to them:Two things that will otherwise confuse the result. Warm the cache first: identical inputs
reuse the prior verdict in under 0.1 ms, so a loop over one string measures your cache, not your
detectors. Vary the input to measure the real path. And run this from where your app runs:
from a laptop you are largely measuring your own internet connection, not PromptGuard.
processing_time_ms from
your event telemetry instead, that field excludes both the network hop and any upstream provider
call. The Analytics Cookbook has the SQL.
Next steps
Analytics Cookbook
Measure your real p50/p95/p99 by detector and surface
Threat Detection
What each detector catches
Reliability
Fail-open vs fail-closed and graceful degradation
Rate Limits
Throughput and quota behavior