Skip to main content
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 as processing_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, and on an attack the regex layer catches you usually do not. Only the slow path is opt-in: LLM-judge detectors run when a project enables them.

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.
No single figure here is your latency. The regex-only and regex + ML rows are three orders of magnitude apart on the same inputs, and the production row is an order of magnitude above the benchmark: what you see is dominated by how often your traffic reaches the ML and LLM tiers and how long your inputs are. Measure your own traffic (below) rather than adopting any of these figures.

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.”
A model that writes a long reasoning trace before answering can blow the budget on the LLM-guard slow path: it spends its token allowance (LLM_GUARD_MAX_TOKENS, default 512) “thinking” and is cut off before emitting the verdict JSON, which then fails open. The default, openai/gpt-oss-20b, was chosen because it returned a correct, parseable verdict on every case of our August 2026 evaluation, with a median response of 1.5 s. If you override LLM_GUARD_MODEL, check the model answers within the budget, and raise LLM_GUARD_MAX_TOKENS for one that reasons at length.

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 carries detection_incomplete so a provider outage stays distinguishable from a period with no threats.
  • fail_mode: closed: the request is refused with 503 detection_unavailable, exactly as it would be for a detector that errored. Content we did not finish evaluating is not forwarded.
A partial scan that did find something still blocks. The finding is not weakened by the windows that were skipped. Your own custom patterns are not skipped because the budget ran out. Like the built-in fast path, they still run, within a further 1 s shared by all of them, so a scan that spent its budget can take up to that much longer to answer. A pattern that cannot finish in that time is reported as 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. api for recall, off for the lowest, most predictable latency, local for the classifiers in-process with no call to hosted inference.
  • Set fail_mode deliberately. open favors availability (allow on engine error); closed favors safety (block on error). Zero-trust projects should run closed and accept that a slow/unreachable detector then blocks rather than falls open. Set it per project at creation, or later via PATCH /dashboard/projects/{project_id}/settings with {"fail_mode": "closed"}; a project that has never set it is open.
  • 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_ms through 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 histogram promptguard_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:
Every budget figure in the tables above is a bucket edge, so a p99 against its budget is read off the histogram rather than estimated between two edges. On Cloud this endpoint is not open to customers; use 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.
To compare against the engine-only budgets in the tables above, query 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
Last modified on November 10, 2026