Protect an AI agent from prompt injection in fetched web pages
How can I scan a web page or text for prompt injection before my AI agent reads it?
Send the text, or the page URL, to POST /v1/safety/injection-scan before the agent reads it. It returns a risk level (none, low, medium or high) and each finding with its kind, offset and an excerpt: hidden instructions, chat-template and role markers, tool-call bait, requests for keys or seed phrases, exfiltration links and invisible characters.
Example: a comment with a hidden instruction
Example call: safety-injection-scan
Body
| Field | Values |
|---|---|
| text | Text to scan, up to 100,000 characters |
| url | A page to fetch and scan, hidden parts included. Send this or text. |
What it detects
- Hidden instructions such as “ignore previous instructions”, role impersonation and chat-template markers.
- Tool-call bait, requests for API keys or seed phrases, and links that would exfiltrate data.
- Invisible text: zero-width characters, bidi overrides, Unicode tag characters, variation-selector payloads, hidden HTML elements and HTML comments, long base64 blobs.
The scan is pattern-based with no model: fast and deterministic, but risk none does not prove text is safe. It lowers the risk; it does not make third-party text safe to obey.
Scanning built into page reading
GET /v1/web/read runs the same kind of check on every page it reads and reports it in injection_risk and injection_warnings, without removing anything. Every paid call through the Octio gateway is also scanned before it is charged: a provider response that looks like instructions aimed at agents fails with UPSTREAM_SUSPICIOUS_CONTENT and costs nothing.
FAQ
What is prompt injection?
Text written to make a language model follow new instructions, hidden in content the model reads, such as a web page, a PDF, an email or a tool result.
Does the scanner use an LLM?
No. It uses patterns and character checks, so the same input always gives the same answer, quickly.
Can it scan a URL directly?
Yes. Send url instead of text and it fetches the page and scans it, hidden parts included.
Updated 2026-11-16.