v0.3.0 Stable Apache 2.0 Python 3.9+

Protect your
LLM apps in
3 lines of code

Open-source security middleware for LLM applications. Block prompt injection, detect PII leaks, and filter harmful outputs — before they reach your users.

$ pip install aig-guardian
<2ms overhead 99.2% detection rate 500+ weekly downloads
app.py
from fastapi import FastAPI
from ai_guardian import Guardian

app = FastAPI()

# ✅ Add ai-guardian in 3 lines
guardian = Guardian(
    detect_injection=True,
    mask_pii=True,
    filter_output=True,
)
app.add_middleware(GuardianMiddleware, guardian=guardian)

@app.post("/chat")
async def chat(prompt: str):
    # Your LLM call — guardian handles the rest
    return llm.generate(prompt)
$ ai-guardian scan --test
✓ Prompt injection: BLOCKED
✓ PII detected: john@example.com → [EMAIL]
✓ Output filter: CLEAN
Protected in 1.4ms

LLMアプリのセキュリティ課題

LLMを本番環境に導入する際、見落とされがちな3つのリスク。

🎭

Prompt Injection

悪意あるユーザーが命令を埋め込み、LLMの挙動を乗っ取る攻撃。システムプロンプトの漏洩や、意図しない操作が実行されるリスク。

🔓

PII Leakage

個人情報(氏名・メール・電話番号・クレジットカード番号)がLLMの入出力に混入し、コンプライアンス違反となるリスク。

⚠️

Harmful Output

LLMが有害・不適切なコンテンツを生成するリスク。フィルタなしでは誤情報、差別的表現、機密情報の漏洩が起こりうる。

本番LLMに必要な
セキュリティを、すべて。

設定不要でゼロデイ保護。エンタープライズレベルのセキュリティをOSSで。

🎯

Prompt Injection Detection

独自のパターンマッチング + LLMベースの二段階検知でプロンプトインジェクションを99.2%の精度でブロック。

Core
🔍

PII Detection & Masking

氏名・メール・電話・クレジットカード・SSN・住所を自動検出し、リアルタイムでマスキング。GDPR/SOC2対応。

Privacy
🚫

Output Filter

LLMの出力を有害コンテンツ・機密情報漏洩・ハルシネーションのリスク観点でフィルタリング。カスタムルール対応。

Output

FastAPI Middleware

FastAPIアプリに1行追加するだけで全エンドポイントを保護。リクエスト・レスポンス両方をインターセプト。

Integration
🔗

LangChain Integration

LangChainのChain・Agentに対応したカスタムCallbackHandler。既存パイプラインを変えずに保護を追加。

Integration
🔄

OpenAI Proxy

OpenAI API互換のプロキシサーバーとして動作。既存コードをゼロ変更で保護。Azure OpenAIも対応。

Proxy

5分で本番保護を開始

3ステップで既存のLLMアプリにセキュリティレイヤーを追加できます。

1

Install

terminal
pip install aig-guardian

# With optional extras
pip install aig-guardian[fastapi,langchain]
2

Configure

guardian.yaml
injection:
  enabled: true
  sensitivity: high

pii:
  mask: [email, phone, name]
  action: replace

output:
  harmful_content: true
  custom_rules: [./rules.yaml]
3

Protect

app.py
from ai_guardian import Guardian

g = Guardian.from_config(
    "guardian.yaml"
)

# That's it. You're protected.
result = g.protect(prompt)

あらゆるスタックに対応

FastAPI、LangChain、OpenAI — 主要フレームワークへの統合コード例。

fastapi_app.py
from fastapi import FastAPI
from ai_guardian.integrations.fastapi import GuardianMiddleware
from ai_guardian import Guardian

app = FastAPI()

# Initialize guardian
guardian = Guardian(
    detect_injection=True,
    mask_pii=True,
    filter_output=True,
)

# Add as middleware — all routes are now protected
app.add_middleware(GuardianMiddleware, guardian=guardian)

@app.post("/api/chat")
async def chat_endpoint(body: ChatRequest):
    # Guardian automatically checks input before this runs
    response = await llm.agenerate(body.prompt)
    # And filters output before returning to user
    return {"response": response}
langchain_chain.py
from langchain.chains import LLMChain
from langchain.llms import OpenAI
from ai_guardian.integrations.langchain import GuardianCallback

# Drop-in callback — no chain modification needed
guardian_cb = GuardianCallback(
    on_injection="block",    # block | warn | log
    on_pii="mask",
    on_harmful="replace",
)

chain = LLMChain(
    llm=OpenAI(temperature=0),
    prompt=prompt,
    callbacks=[guardian_cb],  # ← add this
)

# Agents work too
from langchain.agents import initialize_agent
agent = initialize_agent(
    tools, llm,
    callbacks=[guardian_cb],
)
openai_proxy.py
# Option 1: Drop-in proxy (zero code change)
ai_guardian proxy --port 8080 --target https://api.openai.com

# Set OPENAI_BASE_URL in your existing code
export OPENAI_BASE_URL=http://localhost:8080

---

# Option 2: Python wrapper
from ai_guardian.integrations.openai import protected_client
import openai

# Wraps openai.OpenAI with guardian
client = protected_client(
    api_key=os.environ["OPENAI_API_KEY"],
    guardian_config="guardian.yaml",
)

# Use exactly like openai.OpenAI
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": prompt}]
)

セキュリティはオープンであるべき

セキュリティツールがブラックボックスでは、本当の信頼は生まれない。
だからai-guardianはOSSです。

🔬

完全な透明性

検知ロジック・フィルタリングルール・判定根拠をすべてコードで確認できる。「なぜブロックされたか」が常にわかる。

🌍

コミュニティ駆動

世界中のセキュリティ研究者・開発者が脆弱性の発見・パッチ・新しい攻撃パターンへの対応に貢献している。

🔧

フルカスタマイズ

業界固有のルール、独自の検知モデル、カスタムPIIパターンを追加可能。ベンダーロックインなし。

ai-guardianを搭載した製品

OSSエンジンの上に、エンタープライズ向けSaaSを構築しています。

🛡️ ai-guardian Inside

Helm — Meeting AI

ai-guardianをセキュリティ基盤として搭載した、大企業向けセキュア会議インテリジェンスSaaS。 会議の議事録・意思決定・組織ナレッジを、エンタープライズグレードのセキュリティで管理します。

  • PII自動マスキング(ai-guardian搭載)
  • プロンプトインジェクション防止
  • Human-in-the-Loop 監査フロー
Helmの詳細を見る →
🛡️ Guardian Status
Prompt Injection: Protected
PII Masking: Active
Output Filter: Enabled
📝 Latest Meeting Summary
Q1経営会議 — 意思決定3件を記録
参加者: [NAME]氏, [NAME]氏 ほか4名
PIIマスク済み by ai-guardian

今すぐ保護を始めよう

pip install one line. Zero config. Production ready.