Check a prompt or text fragment for known PROMPT IOC patterns.
Uses an in-memory hash set for sub-1ms token-level querying — no
network calls after the cache is warmed. Slides a window of 3, 5, 8,
and 10 tokens across the input and checks each window's canonical
SHA256 against the PROMPT IOC feed.
This is the primary real-time prompt injection detection endpoint.
Call it on every user-supplied prompt before passing to the LLM.
Args:
text: The prompt text to check (raw, any length)
auto_warm: If True and cache is empty, warm it first (adds ~300ms
on first call only). Default True.
Returns:
matched: True if a known PROMPT IOC pattern was detected
matched_hash: SHA256 of the matching token window (if matched)
window_text: The matched token window text (if matched)
window_size: Number of tokens in the matching window
token_offset: Position in the token stream where match starts
latency_us: Query latency in microseconds
cache_size: Number of PROMPT IOC hashes currently cached
Connector