Documentation Index
Fetch the complete documentation index at: https://docs.benchspan.com/llms.txt
Use this file to discover all available pages before exploring further.
- Node 18+ (uses native
fetch) - Zero runtime dependencies beyond what you already have for your agent framework
- ESM only
BenchGuard
Config
Bearer API key from Dashboard → API Keys. Format:
ag_live_....Optional label to tag every scan from this instance.
In block mode,
scanOrThrow throws InjectionDetectedError on injection. Framework integrations (asAgentHooks, asLangChainCallback, asMiddleware, asAdkCallback) use scanOrThrow internally, so block mode aborts before the LLM call. In warn mode, those integrations fire the scan as an unawaited Promise so your LLM call proceeds with zero added latency; detections land in your dashboard asynchronously.Override the API host. Used for self-hosted deployments.
Methods
guard.scan(input, options?) → Promise<ScanResult>
Scan a single string. Returns the verdict; does not throw on injection.
guard.scanOrThrow(input, options?) → Promise<ScanResult>
Same as scan, but throws InjectionDetectedError when the verdict is block (in block mode) and logs a warning when it’s warn. Always synchronous; use the framework integrations for zero-latency warn-mode behavior.
guard.wrapCall(messages, fn)
Scans an array of chat messages, then invokes fn(). Throws before fn() runs if an injection is found.
system and assistant roles are skipped.
guard.asAgentHooks()
Returns an object with onToolEnd(context, agent, tool, result) for the OpenAI Agents SDK. See OpenAI Agents integration.
guard.asLangChainCallback()
Returns a LangChain JS callback object with handleChatModelStart and handleLLMStart. See LangChain integration.
guard.asMiddleware()
Returns a Vercel AI SDK middleware with transformParams. Scans the prompt before the model is invoked. See Vercel AI SDK integration.
guard.asAdkCallback()
Returns a beforeModelCallback for the Google ADK. Scans every part of every content before the LLM call. See Google ADK integration.
Types
ScanResult
BenchGuardConfig
ScanOptions
InjectionDetectedError
scanOrThrow, wrapCall, and all framework integrations when verdict === "block".