Back to blog
SafePrompt Team
7 min read

AI Security Has No Standard API. That Needs to Change.

Why AI Security Needs an API Standard (And What It Should Look Like)

Also known as: AI security gateway spec, prompt injection API standard, vendor-neutral AI securityAffecting: LLM applications, AI chatbots, AI agents, enterprise AI

Every infrastructure category has a standard API. AI security has none. Here's why vendor lock-in in a security-critical layer is dangerous, and what the standard should look like.

AI SecurityAPI StandardInteroperabilityThought Leadership

TLDR

AI security has no standard API — every vendor uses a different interface, creating dangerous vendor lock-in for a security-critical layer. The fix is a simple OpenAPI 3.1 spec (ai-security-gateway-spec) that defines a common validate endpoint, shared response schema, and threat taxonomy. SafePrompt publishes the reference implementation at safeprompt.dev/openapi.yaml.

Quick Facts

Auth standard:OAuth 2.0 / OIDC
Payments standard:Stripe-compatible APIs
Observability standard:OpenTelemetry
AI security standard:None

Every Infrastructure Category Has a Standard. Except This One.

Think about the last time you integrated authentication. You probably used OAuth 2.0 or OIDC. You didn't have to choose between incompatible auth systems — you chose a provider (Auth0, Clerk, Supabase), and the interface was standardized.

Same for payments. Stripe defined the interface. Dozens of services are Stripe-compatible. You can switch processors without rewriting your checkout code.

Same for observability. OpenTelemetry defined the interface. Your traces work across Datadog, Honeycomb, Jaeger — any backend that speaks OTLP.

AI security has none of this. Every vendor — Lakera, NeMo Guardrails, and SafePrompt — ships a different API shape, different field names, different threat taxonomies. There's no way to swap vendors without rewriting every integration.

Why This Is Specifically Bad for Security

Vendor lock-in is annoying in most categories. In security, it's dangerous for a few specific reasons:

1. You can't respond fast to vendor incidents

If your AI security vendor goes down, gets breached, or raises prices 10x, you're stuck. Switching takes weeks of engineering time — time during which your app is either unprotected or offline. With a standard interface, you switch in an hour.

2. Threat categories aren't comparable

Lakera returns flagged: true with a category string. SafePrompt returns safe: false with a typed threat array. Others return numeric risk scores. Without a shared taxonomy, you can't benchmark, compare, or audit what different services actually detect.

3. No secondary validation

Defense-in-depth is a core security principle. Running two AI security checks — one primary, one secondary for high-stakes decisions — is currently impractical because every integration is custom. A standard would make layered AI security as easy as adding a second DNS provider.

What the Standard Should Look Like

The spec doesn't need to be complex. The UNIX philosophy applies: do one thing well. An AI security gateway should validate a prompt and return a structured result.

ai-security-gateway-spec v1.0yaml
# ai-security-gateway-spec v1.0
POST /api/v1/validate
  Body:  { prompt: string, sessionToken?: string }
  Header: X-API-Key, X-User-IP

Response:
  {
    safe: boolean,
    threats: string[],
    confidence: number,       // 0.0 – 1.0
    processingTimeMs: number,
    passesUsed: number
  }

Three endpoints. That's it.

  • /api/v1/validate — single prompt check
  • /api/v1/validate/batch — batch check (up to 10 prompts)
  • /api/v1/usage — quota and billing info

The response schema is the important part. safe: boolean is the primary decision signal. threats: string[] uses a shared enum so you can write logic like if threats.includes('system_prompt_extraction')that works across any compliant vendor.

What Changes With a Standard

Today, switching AI security vendors looks like this:

before-standard.jsjavascript
// Today: vendor lock-in
import Lakera from '@lakera/guard'
const guard = new Lakera({ apiKey: process.env.LAKERA_KEY })
const result = await guard.detect({ input: userMessage })
if (result.flagged) throw new Error('Blocked')

// Switching vendors = rewriting every integration

With a standard interface, every vendor looks the same to your code:

after-standard.jsjavascript
// With a standard: swap freely
import SafePrompt from 'safeprompt'
const sp = new SafePrompt({ apiKey: process.env.SAFEPROMPT_KEY })
const result = await sp.check(userMessage)
if (!result.safe) throw new Error('Blocked')

// Same interface. Any compliant vendor works.

The only thing that changes is which API key you configure. Your application code — the part that handles blocked prompts, logs threat categories, and alerts on anomalies — stays identical.

The Threat Taxonomy Matters as Much as the Schema

Half the value of a standard is the shared vocabulary. The spec defines nine threat categories that cover the full OWASP LLM Top 10 attack surface:

instruction_override

Direct "ignore all previous" commands

jailbreak

DAN, developer mode, character breaks

system_prompt_extraction

Attempts to leak system instructions

data_exfiltration

Stealing context or conversation data

encoding_bypass

Base64, ROT13, Unicode obfuscation

roleplay_manipulation

Persona hijacking via roleplay framing

multi_turn_attack

Slow-burn attacks across sessions

hidden_text_injection

Zero-width chars, invisible CSS

policy_puppetry

XML/JSON formatted override attempts

Using shared category names means your alerting, logging, and incident response tooling works regardless of which vendor detected the threat.

SafePrompt Is the Reference Implementation

We're publishing the full OpenAPI 3.1 spec and implementing it exactly. SafePrompt's API already conforms to the spec — if you build against the spec, SafePrompt works out of the box.

Get the spec

  • OpenAPI 3.1 spec: safeprompt.dev/openapi.yaml
  • GitHub: github.com/ianreboot/safeprompt
  • npm SDK: npm install safeprompt
  • Python SDK: pip install safeprompt (coming soon)

What We're Asking For

We're not asking Lakera or anyone else to adopt our API shape verbatim. We're proposing a conversation: what should the standard look like?

The AI security category is young enough that we can still establish interoperability before lock-in calcifies. Auth took until OAuth 2.0 (2012) to get a standard — eight years after the category existed. Payments took even longer.

AI security is two years old. Now is the time to get this right.

If you're building an AI security product and want to collaborate on the spec, open an issue at github.com/ianreboot/safeprompt or email [email protected].

Protect Your AI Applications

Don't wait for your AI to be compromised. SafePrompt provides enterprise-grade protection against prompt injection attacks with just one line of code.