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
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)
LLMを本番環境に導入する際、見落とされがちな3つのリスク。
悪意あるユーザーが命令を埋め込み、LLMの挙動を乗っ取る攻撃。システムプロンプトの漏洩や、意図しない操作が実行されるリスク。
個人情報(氏名・メール・電話番号・クレジットカード番号)がLLMの入出力に混入し、コンプライアンス違反となるリスク。
LLMが有害・不適切なコンテンツを生成するリスク。フィルタなしでは誤情報、差別的表現、機密情報の漏洩が起こりうる。
設定不要でゼロデイ保護。エンタープライズレベルのセキュリティをOSSで。
独自のパターンマッチング + LLMベースの二段階検知でプロンプトインジェクションを99.2%の精度でブロック。
Core氏名・メール・電話・クレジットカード・SSN・住所を自動検出し、リアルタイムでマスキング。GDPR/SOC2対応。
PrivacyLLMの出力を有害コンテンツ・機密情報漏洩・ハルシネーションのリスク観点でフィルタリング。カスタムルール対応。
OutputFastAPIアプリに1行追加するだけで全エンドポイントを保護。リクエスト・レスポンス両方をインターセプト。
IntegrationLangChainのChain・Agentに対応したカスタムCallbackHandler。既存パイプラインを変えずに保護を追加。
IntegrationOpenAI API互換のプロキシサーバーとして動作。既存コードをゼロ変更で保護。Azure OpenAIも対応。
Proxy3ステップで既存のLLMアプリにセキュリティレイヤーを追加できます。
pip install aig-guardian
# With optional extras
pip install aig-guardian[fastapi,langchain]
injection:
enabled: true
sensitivity: high
pii:
mask: [email, phone, name]
action: replace
output:
harmful_content: true
custom_rules: [./rules.yaml]
from ai_guardian import Guardian
g = Guardian.from_config(
"guardian.yaml"
)
# That's it. You're protected.
result = g.protect(prompt)
FastAPI、LangChain、OpenAI — 主要フレームワークへの統合コード例。
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}
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],
)
# 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パターンを追加可能。ベンダーロックインなし。
OSSエンジンの上に、エンタープライズ向けSaaSを構築しています。
ai-guardianをセキュリティ基盤として搭載した、大企業向けセキュア会議インテリジェンスSaaS。 会議の議事録・意思決定・組織ナレッジを、エンタープライズグレードのセキュリティで管理します。
pip install one line. Zero config. Production ready.