client.chat.completions.create() with two InferenceWall scanning checkpoints: one before the prompt reaches OpenAI to catch prompt injection and jailbreaks, and one before the response reaches your user to catch PII, API keys, and other sensitive data leakage.
Install
Steps
1
Scan the input before calling OpenAI
Call The
inferwall.scan_input() with the user’s prompt. Check decision and return early if the request is blocked.ScanResponse object exposes three fields you’ll use most:2
Call OpenAI for allowed requests
If the input passes, forward the prompt to OpenAI as normal.
3
Scan the output before returning it
Call
inferwall.scan_output() on the LLM’s response. Block the reply if it contains sensitive data.4
Handle flag decisions
A
"flag" decision means InferenceWall detected suspicious content but did not meet the block threshold. Use flags for logging, alerting, or human review — or promote them to blocks by treating "flag" the same as "block" in your conditional.Complete example
What gets blocked
InferenceWall applies different signature sets to inputs and outputs.
- Prompt injection (
Ignore all previous instructions…) - Jailbreak attempts (DAN, persona hijacking, role-play bypasses)
- Obfuscated payloads (base64-encoded instructions, homoglyphs, ROT13)
- PII (email addresses, phone numbers, national ID numbers)
- Credentials and API keys (
sk-…,AKIA…, private keys) - Training data exfiltration patterns