Prompt Shield API
The Prompt Shield API lets you scan prompts and responses from any application. You do not need to use SecureAI’s built-in chatbot infrastructure. Integrate the scanning engine into your own LLM pipeline with three REST endpoints. Prompt Shield can be used two ways:- Standalone scanning API — the
/scan,/scan-output, and/scan-conversationendpoints documented below, for your own LLM pipeline. - Inline on completions — when you call Chat Completion or the OpenAI-compatible endpoint, Prompt Shield runs automatically and can be tuned per call. See Per-call control on completions.
Per-call control on completions
Completion requests scan input (and output) through Prompt Shield automatically when the API key has it enabled. You can override the behavior for a single call with aprompt_shield object in the request body:
You cannot combine
policy with enabled: false. The applied policy is echoed back on the response (metadata.prompt_shield_policy on the classic endpoint, secureai.prompt_shield_policy on the /v1 endpoint). To preview a call’s verdict without running the model, use Policy Check.
Authentication
All Prompt Shield API requests require a SecureAI API key in theAuthorization header:
Base URL
POST /scan
Scan a single user prompt for injection attacks before sending it to your LLM.Request
Response
Recommended Integration Pattern
POST /scan-output
Scan an LLM response for evidence of compromise, including system prompt leakage, canary token leakage, or role drift.Request
Response
POST /scan-conversation
Scan an entire multi-turn conversation at once. This is useful for batch analysis or for evaluating historical conversations for retroactive detection.Request
Response
Error Responses
Rate Limits & Performance
- Scan latency is typically 1-5 ms for the regex and heuristic layers.
- Adding the ML layer increases latency to 20-50 ms depending on the embedding provider.
- The external API shares rate limits with the rest of your API key allocation.
- The circuit breaker returns
503responses if the engine experiences 5 consecutive failures within 30 seconds.
Enabling Prompt Shield on an API Key
- Go to Admin -> API Keys.
- Edit the API key you use for external calls.
- Toggle Enable Prompt Shield on.
- Optionally set Prompt Shield Sensitivity to
strict,balanced, orpermissive. - Optionally set Prompt Shield Policy to bind a specific policy to this key.
- Save.
/api/external/prompt-shield/* requests made with this key go through the engine with the configured policy.
