Reference

HTTP API

Base URL https://promptflowengine.com/api/v1. JSON in, JSON out. No authentication and nothing is stored; prompt text is never logged. Every response carries an x-request-id header.

For bulk or sensitive work, run the same engine locally with the CLI: no network, no rate limits.

Endpoints

MethodPathBodyReturns
GET/health—status, engine and API versions
GET/models—model catalogue with encodings and reference prices
GET/rules—rule catalogue, dimensions, penalties
POST/analyzeprompt, model?findings, quality, tokens, security, requirements, intent
POST/validatepromptvalid (no critical findings), findings
POST/optimizeprompt, model?, mode?, goal?, tokenBudget?selected candidate, all candidates with verification, changes, diff, deltas, suggestions
POST/comparea, b, model?diff, token/cost/quality deltas, findings resolved and introduced
POST/tokensprompt, model?token count, method, per-section counts, estimated cost
POST/scanpromptinjection risk and signatures, sensitive-data counts and offsets, undelimited variables
POST/sanitizetexttext with sensitive values replaced by placeholders

mode: conservative | balanced | structured. goal: tokens | quality | balanced. model: any id from /models (default gpt-4.1).

Example

curl
curl -s https://promptflowengine.com/api/v1/optimize \
  -H 'content-type: application/json' \
  -d '{"prompt":"Please summarize the notes. Please summarize the notes.","mode":"balanced"}' \
  | jq '{selected: .selected.text, tokenDelta, changes: [.changes[].title]}'

With "goal":"tokens" the engine would instead keep Please summarize the notes.: a sentence-initial Summarize costs two tokens, so that candidate is one token cheaper.

response (abridged, real output)
{
  "selected": "Summarize the notes.",
  "tokenDelta": -4,
  "changes": ["Removed repeated sentences", "Removed filler and politeness phrases"]
}

Limits

  • Request body up to 256 KB; each text field up to 100,000 characters.
  • 60 POST requests per minute per client IP. Over the limit you get 429 with retry-after: 60.
  • CORS is open (*) without credentials, so browsers can call the API directly.

Errors

error envelope
{ "error": { "type": "invalid_request", "message": "\"prompt\" is required.", "requestId": "…" } }
Statustype
400invalid_request: missing or wrong-typed field, bad JSON, wrong content type
404not_found: unknown endpoint or API version
405method_not_allowed
413payload_too_large
429rate_limited
500internal_error (no internal details are exposed)