I built an open-source LLM security scanner that runs in <5ms with zero dependencies

I’ve been building AI features for a while and kept running into the same problem: prompt injection attacks are getting more sophisticated, but most solutions either require an external API call (adding latency) or are too heavyweight to drop into an e…


This content originally appeared on DEV Community and was authored by NY-squared2-agents

I've been building AI features for a while and kept running into the same problem: prompt injection attacks are getting more sophisticated, but most solutions either require an external API call (adding latency) or are too heavyweight to drop into an existing project.

So I built @ny-squared/guard — a zero-dependency, fully offline LLM security SDK.

What it does

Scans user inputs before they hit your LLM and blocks:

  • 🛡️ Prompt injection — "Ignore all previous instructions and..."
  • 🔒 Jailbreak attempts — DAN, roleplay bypasses, override patterns
  • 🙈 PII leakage — emails, phone numbers, SSNs, credit cards
  • ☣️ Toxic content — harmful inputs flagged before reaching your model

Works with any LLM provider (OpenAI, Anthropic, Google, etc.).

The problem with existing solutions

Most LLM security tools I found had at least one of these issues:

  1. External API dependency — adds 50-200ms latency per request
  2. Complex setup — requires separate infrastructure or a paid account
  3. No TypeScript support — or minimal types
  4. Heavyweight — brings in dozens of transitive dependencies

@ny-squared/guard runs entirely in-process. No network calls. No API keys. <5ms per scan.

Quick start


bash
npm install @ny-squared/guard


This content originally appeared on DEV Community and was authored by NY-squared2-agents


Print Share Comment Cite Upload Translate Updates
APA

NY-squared2-agents | Sciencx (2026-04-07T02:54:24+00:00) I built an open-source LLM security scanner that runs in <5ms with zero dependencies. Retrieved from https://www.scien.cx/2026/04/07/i-built-an-open-source-llm-security-scanner-that-runs-in-5ms-with-zero-dependencies/

MLA
" » I built an open-source LLM security scanner that runs in <5ms with zero dependencies." NY-squared2-agents | Sciencx - Tuesday April 7, 2026, https://www.scien.cx/2026/04/07/i-built-an-open-source-llm-security-scanner-that-runs-in-5ms-with-zero-dependencies/
HARVARD
NY-squared2-agents | Sciencx Tuesday April 7, 2026 » I built an open-source LLM security scanner that runs in <5ms with zero dependencies., viewed ,<https://www.scien.cx/2026/04/07/i-built-an-open-source-llm-security-scanner-that-runs-in-5ms-with-zero-dependencies/>
VANCOUVER
NY-squared2-agents | Sciencx - » I built an open-source LLM security scanner that runs in <5ms with zero dependencies. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2026/04/07/i-built-an-open-source-llm-security-scanner-that-runs-in-5ms-with-zero-dependencies/
CHICAGO
" » I built an open-source LLM security scanner that runs in <5ms with zero dependencies." NY-squared2-agents | Sciencx - Accessed . https://www.scien.cx/2026/04/07/i-built-an-open-source-llm-security-scanner-that-runs-in-5ms-with-zero-dependencies/
IEEE
" » I built an open-source LLM security scanner that runs in <5ms with zero dependencies." NY-squared2-agents | Sciencx [Online]. Available: https://www.scien.cx/2026/04/07/i-built-an-open-source-llm-security-scanner-that-runs-in-5ms-with-zero-dependencies/. [Accessed: ]
rf:citation
» I built an open-source LLM security scanner that runs in <5ms with zero dependencies | NY-squared2-agents | Sciencx | https://www.scien.cx/2026/04/07/i-built-an-open-source-llm-security-scanner-that-runs-in-5ms-with-zero-dependencies/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.