SafePrompt · Prompt injection detection API
Get a free API key
SafePrompt
Prompt injection detection API for LLM apps and agents.
For AI agents and MCP

Screen prompt injection in agent inputs and tool results

Your agent reads documents, tool results and messages from other agents. SafePrompt screens the text your application submits, and your code withholds unsafe results before the next model call.

Key points

SafePrompt screens text your application submits before model consumption: tool results, retrieved documents and inter-agent messages. One POST to /api/v1/validate returns JSON with safe true or false, a confidence score, and the threat categories that fired. Most checks come back in under a second. It works with any model provider, because it validates the content rather than the model.

Start with your email. No card.

By continuing you agree to the Terms of Service and the Privacy Policy.

10,000 free validations a month on the free plan.

SafePrompt checks every input, not just the first one

A chatbot reads one thing: the user's message. An agent reads many things it did not write. It pulls documents from a vector store, calls tools over MCP, browses pages and passes results between sub-agents. Every one of those is a place an instruction can arrive, and that is where modern attacks land. SafePrompt drops in at each checkpoint, so the whole pipeline is covered rather than the front door.

What are the three ways an agent gets injected?

SafePrompt reads the content at all three, so a hidden instruction has to get past a check before it can become an action. One gap today: it does not yet catch instructions hidden in an MCP tool description, so review the descriptions of every server you install.

Indirect injection

A retrieved document, web page or email carries hidden instructions that your agent reads as if you typed them. The user prompt looked clean. The data did not.

Tool poisoning

An MCP tool description or a tool result smuggles redirect instructions into the loop, steering the agent toward an action you never approved.

Cross-context bleed

An injection that enters through one tool or sub-agent rides along into the next call, so a single poisoned step can reach the whole chain.

How it scores against the benchmarks

On AgentDojo, a public agent benchmark, SafePrompt cut successful attacks from 239 to 4 out of 949. Screening tool output has a cost you can measure too. Under attack the agent finished its task in 131 of 949 runs with SafePrompt, against 400 undefended. With no attack planted, it finished 64 of 97 tasks with SafePrompt and 68 without.

Agent attacks that reached their goal with SafePrompt (AgentDojo, four suites)4 of 949
The same attacks with no defence239 of 949
Direct hijack attempts caught (TensorTrust)88%
Jailbreak attempts caught (HackAPrompt)92%
Ordinary messages passed (TensorTrust benign set, 200 access codes)97%
Ordinary messages passed (BIPIA, documents and retrieved content)97%

Production API in strict mode, public sets 10 October 2026. AgentDojo: GPT-4o-mini agent, 21 to 22 October 2026.

Every per-case result is in the public repository.

Benchmark facts last reviewed: 26 October 2026

Install it in one function

Place the HTTP call before your agent reads untrusted text. Submit the exact tool result, retrieved chunk or inter-agent message. Authorize tool execution separately using the authenticated user and action arguments.

// Run on the server. Resolve endUserIp at your trusted proxy boundary.
async function screenText(text, endUserIp, timeoutMs) {
  if (typeof text !== 'string' || !text.trim() || !endUserIp ||
      !Number.isFinite(timeoutMs) || timeoutMs <= 0) {
    throw new Error('Invalid screening input')
  }
  const controller = new AbortController()
  const timer = setTimeout(() => controller.abort(), timeoutMs)
  try {
    const res = await fetch('https://api.safeprompt.dev/api/v1/validate', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        'X-API-Key': process.env.SAFEPROMPT_API_KEY,
        'X-User-IP': endUserIp,
      },
      body: JSON.stringify({ prompt: text }),
      signal: controller.signal,
    })
    if (!res.ok) throw new Error('Screening unavailable')
    const result = await res.json()
    if (typeof result.safe !== 'boolean') throw new Error('Invalid verdict')
    if (!result.safe) throw new Error('Content withheld by screening')
    return { text }
  } finally {
    clearTimeout(timer)
  }
}

// Errors, malformed responses and timeouts must prevent the next model call.
const accepted = await screenText(toolResultText, endUserIp, applicationDeadlineMs)
await sendToolResultToAgent(accepted.text)

Estimate the checks in your agent loop

Each submitted text item uses a validation. A user message and four tool results need five checks before retries. Test exact serialized content, attacks and ordinary tasks together. SafePrompt checks each request on its own and does not track sessions. To have several turns judged together, send them in one check. Keep conversation state in your app.

Plan pricing · Coverage limits · Complete integration contract

It travels with your agent, across every provider

SafePrompt validates submitted text, so your app can place a checkpoint at each input boundary, whoever serves the tokens. Your pipeline can change providers without changing your security layer.

Use Azure Prompt Shields if your stack lives entirely in Azure. Use Bedrock Guardrails if everything runs in Bedrock. Use a model provider's own filter if one model serves your whole pipeline and the chat box is the only input you take. Agent pipelines usually span more than one of those. Our Azure Prompt Shields comparison sets the first of those choices next to ours.

Questions developers ask first

Does SafePrompt work with any MCP server?

You can call the API at input boundaries you control in an MCP server or orchestrator. It screens the text you submit; registering a callback does not establish coverage of every tool or event. Verify propagation, serialization and error handling in your installed framework.

What does it cost in latency to check every tool input?

Most checks come back in under a second. The median and the 95th percentile are measured continuously on production traffic and published on this site, so you can size the check against your own agent loop before you add the call.

Does it work with LangChain, LlamaIndex and CrewAI?

Yes. SafePrompt is a single HTTP POST, so it drops into LangChain, LlamaIndex, CrewAI or any other agent framework. You check content at each checkpoint, whether that is a tool result, a retrieved chunk or an inter-agent message, and block when an injection is detected.

Secure your agents in one call

10,000 free validations a month, on the same detection engine every paid plan runs.

Start with your email. No card.

By continuing you agree to the Terms of Service and the Privacy Policy.

Read the MCP guide · See what it costs · What SafePrompt covers