CleanMyPrompt
Free & Open

API Documentation

Integrate PII redaction and prompt cleaning into your pipeline. No API key required. All processing happens server-side with zero data retention.

Base URL

https://cleanmyprompt.io

Rate Limits

The free public API is rate-limited to 30 requests per minute per IP. For higher limits or dedicated endpoints, contact us.

POST/api/v1/clean

Clean, compress, and redact PII from text in a single call.

Request Body

FieldTypeRequiredDescription
textstringYesThe text to process (max 100,000 chars).
mode"standard" | "squeeze" | "json"NoCleaning mode. Default: "standard".
redactbooleanNoRedact PII (emails, phones, SSNs, etc). Default: true.
aggressivebooleanNoAggressive compression (squeeze mode only). Default: false.
lang"en" | "de" | "fr" | "es"NoLanguage for stop-word aware compression. Default: "en".

Example Request

curl -X POST https://cleanmyprompt.io/api/v1/clean \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Contact Dr. Sarah Johnson at sarah@company.com or call +1-555-0123. My key is sk-proj-abc123def456.",
    "mode": "standard",
    "redact": true
  }'

Response

{
  "cleaned": "Your processed text here...",
  "stats": {
    "originalChars": 1250,
    "cleanedChars": 980,
    "originalTokens": 312,
    "cleanedTokens": 245,
    "tokensSaved": 67,
    "reductionPercent": 21,
    "piiFound": 3,
    "secretsFound": 1,
    "linksFound": 0
  }
}
POST/api/v1/analyze

Scan text for secrets, PII, and links without modifying it.

Request Body

FieldTypeRequiredDescription
textstringYesThe text to analyze (max 100,000 chars).

Example Request

curl -X POST https://cleanmyprompt.io/api/v1/analyze \
  -H "Content-Type: application/json" \
  -d '{
    "text": "My SSN is 123-45-6789 and email is test@example.com"
  }'

Response

{
  "isClean": false,
  "findings": {
    "secrets": 1,
    "pii": 3,
    "links": 0
  }
}
New

AI Agent / MCP Integration

CleanMyPrompt is an MCP-compatible tool that AI agents can call directly. Use it to clean prompts before sending them to any LLM.

MCP Tool Spec

// Add to your MCP client config:
{
  "mcpServers": {
    "cleanmyprompt": {
      "url": "https://cleanmyprompt.io/api/v1"
    }
  }
}

// Tools available:
// - clean_text: Clean, compress, redact
// - analyze_text: Scan for PII/secrets
Download mcp.json →

OpenAI Plugin / ChatGPT

// Plugin manifest:
GET /.well-known/ai-plugin.json

// OpenAPI spec:
GET /openapi.json

// Both are auto-discoverable
// No API key required
Download openapi.json →

Quick Integration

Python

import requests

r = requests.post(
  "https://cleanmyprompt.io/api/v1/clean",
  json={
    "text": "Email me at john@corp.com",
    "redact": True
  }
)
print(r.json()["cleaned"])

JavaScript / Node

const res = await fetch(
  "https://cleanmyprompt.io/api/v1/clean",
  {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      text: "Email me at john@corp.com",
      redact: true,
    }),
  }
);
const { cleaned } = await res.json();

Error Codes

StatusMeaning
400Invalid or missing request body
429Rate limit exceeded (30 req/min)
500Internal server error

Need Higher Limits?

Self-host CleanMyPrompt or contact us for a dedicated enterprise endpoint.