Skip to main content

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:
  1. Standalone scanning API — the /scan, /scan-output, and /scan-conversation endpoints documented below, for your own LLM pipeline.
  2. 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 a prompt_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 the Authorization header:
API keys are created and managed in Admin -> API Keys. To enable Prompt Shield for an API key, edit the key and toggle Enable Prompt Shield. You can optionally bind a specific policy to the key.

Base URL


POST /scan

Scan a single user prompt for injection attacks before sending it to your LLM.

Request

Response


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 503 responses if the engine experiences 5 consecutive failures within 30 seconds.

Enabling Prompt Shield on an API Key

  1. Go to Admin -> API Keys.
  2. Edit the API key you use for external calls.
  3. Toggle Enable Prompt Shield on.
  4. Optionally set Prompt Shield Sensitivity to strict, balanced, or permissive.
  5. Optionally set Prompt Shield Policy to bind a specific policy to this key.
  6. Save.
All /api/external/prompt-shield/* requests made with this key go through the engine with the configured policy.