@zeroleaks/shield weekly downloads statistics
Runtime security for LLM apps and agents: prompt injection detection for user input and tool results, and leak, credential, PII, and exfiltration checks on model output
@zeroleaks/shield has 5,435 recorded weekly downloads on npm, an increase of 619% over the past 30 days, ranking #1492 of 3,247 tracked listings.
About @zeroleaks/shield
@zeroleaks/shield
Prompt injection and jailbreak detection for agents. await detect(text) checks user messages, retrieved documents, and tool results with the hosted Shield API. Provider wrappers apply the check before a model call and check its output for secrets, personal data, and prompt leaks.
Built and maintained by ZeroLeaks. See the migration guide when upgrading from synchronous detect().
Install
bun add @zeroleaks/shield
# or: npm install @zeroleaks/shield
The hosted client uses fetch and supports Node.js 18+, Bun, Deno, Cloudflare Workers, and browsers. Keep dashboard API keys in your server or Worker environment. Provider SDKs and local transformer inference are optional peer dependencies.
For optional local model inference, use a current security-patched Node.js 22 release (22.23.3 or later) or Bun 1.4.2 or later. The local model installation guide pins Transformers 3.8.1 and shows the consumer application override for Sharp 0.35.4, which includes fixes absent from Transformers' default Sharp 0.34.x dependency. The default SDK install does not include either package.
Quick start
Create a zl_live_ key in the ZeroLeaks dashboard. All hosted models require a key, including the free model. Set ZEROLEAKS_API_KEY on your server, or pass apiKey explicitly:
import { detect } from "@zeroleaks/shield";
const result = await detect(untrustedText, {
apiKey: process.env.ZEROLEAKS_API_KEY,
});
if (result.detected) {
throw new Error("The input was blocked.");
}
detected and flagged carry the same verdict. score is the effective binary score; shield.model_score is the model's raw score and shield.rules says whether a rule also flagged the text. The single prompt_injection category includes jailbreaks. It does not provide a separate jailbreak probability.
| Model | Access |
|---|---|
shield (default) | Free, with a dashboard key and research consent |
shield-base | Paid |
shield-large | Paid |
shield-tiered | Paid |
Choose a model with detect(text, { model: "shield-large" }). Free access requires the dashboard research consent flow. Paid requests are excluded from research retention, including when a paid account selects shield.
Protect a model call
Reuse a hosted detector and pass its options to a provider wrapper. The wrapper blocks flagged user messages and tool results before calling the model:
import OpenAI from "openai";
import { createHostedDetector } from "@zeroleaks/shield";
import { shieldOpenAI } from "@zeroleaks/shield/openai";
const shield = createHostedDetector({ model: "shield" });
const client = shieldOpenAI(new OpenAI(), {
detect: shield.options(),
canary: true,
});
const response = await client.chat.completions.create({
model: "your-model",
messages: [
{ role: "system", content: "You are a support agent for Acme." },
{ role: "user", content: userInput },
],
});
For Vercel AI SDK:
import { generateText, wrapLanguageModel } from "ai";
import { openai } from "@ai-sdk/openai";
import { createHostedDetector } from "@zeroleaks/shield";
import { shieldLanguageModelMiddleware } from "@zeroleaks/shield/ai-sdk";
const shield = createHostedDetector();
const model = wrapLanguageModel({
model: openai("your-model"),
middleware: shieldLanguageModelMiddleware({ detect: shield.options() }),
});
const result = await generateText({ model, prompt: userInput });
Pass detect: shield.options() to the other wrappers in the same way. Omitting it preserves the wrappers' existing local detection behavior. The AI SDK middleware waits for detection before the model call. The legacy shieldMiddleware() helper provides await wrapParamsAsync(params) for hosted detection; its synchronous wrapParams() accepts only local synchronous checks.
AI SDK inspection tool
Shield 2.1.2 adds an inspection tool for AI SDK 5, 6, and 7:
import { shieldCheck } from "@zeroleaks/shield/ai-sdk/tools";
const check = shieldCheck(); // Local; no network or API key.
const result = await check.execute(
{ text: "The document's complete original text.", source: "document" },
{}
);
if (result.detected) {
throw new Error("The document was blocked.");
}
Use tools: { shieldCheck: shieldCheck() } with generateText or streamText for model-invoked inspection. Pair it with shieldLanguageModelMiddleware for enforced checks before model calls: the model chooses whether to call the tool and which text to submit. A negative detection is not a guarantee of safety or permission to act. Tool execution errors become AI SDK tool-error parts; application code must decide whether the agent can continue.
Configure local checks with shieldCheck({ detect: { sensitivity: "strict" } }), or opt into hosted checks with shieldCheck({ hosted: { apiKey, model: "shield" } }). Hosted checks always require complete coverage and throw on missing or truncated coverage. Local checks reject oversized input instead of silently truncating it. The executor accepts { abortSignal } as its second argument.
The new subpath requires ai 5 or later; AI SDK 7 requires Node.js 22+. Install ai and its zod peer alongside Shield. Other entry points still work without ai installed, and middleware retains SDK 4 support. See the complete AI SDK tool guide for a runnable model example, result fields, access requirements, and limitations.
Request options…
Description from the npm listing.
- llm
- security
- prompt-injection
- ai-safety
- openai
- anthropic
- gemini
- mistral
- langchain
- jailbreak
- ai-agents
- agent-security
- mcp
- openai-agents
- tool-poisoning
- guardrails
- dlp
- secrets-detection
- pii
- canary
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (157)Similar npm AI SDKs plugins
All 20 @zeroleaks/shield alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@zeroleaks/shield. First seen Oct 19, 2026; last successful collection Dec 6, 2026. See the methodology.