---
title: "AI Shield (Python) · Python port of AI Shield"
description: "Python port of AI Shield. Python LLM security middleware: prompt-injection, PII, tool-policy, cost-budget, audit. Port of ai-shield-core (TypeScript). Same"
canonical: "https://matthiasmeyer.tech/repos/ai-shield-py"
language: "en"
last_updated: "2026-08-19"
markdown_versions: ["https://matthiasmeyer.tech/repos/ai-shield-py.md", "https://matthiasmeyer.tech/de/repos/ai-shield-py.md", "https://matthiasmeyer.tech/es/repos/ai-shield-py.md"]
image: "https://matthiasmeyer.tech/api/og/repo/ai-shield-py?lang=en"
publisher: "Matthias Meyer, https://matthiasmeyer.tech (llms.txt: https://matthiasmeyer.tech/llms.txt)"
---

security stable Python

# AI Shield (Python)

Python port of AI Shield

Python LLM security middleware: prompt-injection, PII, tool-policy, cost-budget, audit. Port of ai-shield-core (TypeScript). Same defense surface, FastAPI/LangChain hooks instead of Hono/Express.

[View on GitHub →](https://github.com/studiomeyer-io/ai-shield-py)[PyPI](https://pypi.org/project/studiomeyer-aishield/)

## What it solves

Most applications built on language models in 2026 ship with no defensive layer between the application and the model call. The TypeScript answer to that is ai-shield, and Python teams had to either port it themselves or go without.

## How it works

It is a one-to-one port of the TypeScript core, which had four audit rounds behind it. The heuristic scanner carries 42 prompt-injection patterns across eight categories, and the whole thing is a small deterministic in-process gate: no network, no external service, no runtime configuration that can drift away from what you tested.

## When to use it

Take it if your stack is Python and you want the same first line of triage the TypeScript side has, with the same patterns and the same behaviour, so a team running both languages does not end up with two different definitions of what gets blocked.

## When not to use it

Everything the TypeScript version says about its own limits applies here unchanged, because it is the same design. A pattern filter inside the same reasoning system as the attack is a first line, not the only one. Read the honesty section on the ai-shield page before you rely on either.

Stars

★ 0

installs

↓ 23

Clones (14d)

⊟ 34

Language

Python

Updated

2026-08-19

## Install

```
pip install studiomeyer-aishield
```

## Related repos

- AI Shield

    → Python port of

    →

    https://matthiasmeyer.tech/repos/ai-shield

- MCP Armor

    → trio with Rust sidecar

    →

    https://matthiasmeyer.tech/repos/mcp-armor

## Sitemap

Every page of this site as Markdown: [sitemap](https://matthiasmeyer.tech/sitemap.md). Curated entry point: [llms.txt](https://matthiasmeyer.tech/llms.txt).
