Image analysis
Extract text from an image with OCR, detect PII and unsafe content in it, and get a redacted copy of the image back.
- Version: 0.4
- Role: admin_user, normal_user
- Type: reference
Run OCR over an image, scan the extracted text with the full detection pipeline, and receive a redacted copy of the image when a detection calls for masking.
Warning
Every /image-analysis route is guarded by the JWT guard alone. A gateway API key
(cid_key_…) cannot call these endpoints — it authenticates only /chat/*, /models and
/api/v1/guardrails/detect.
Analyse an image
POST /image-analysis/analyze
The request is JSON with a base64 payload, not multipart. There is no file-upload field on this endpoint.
| Parameter | Type | Required | Description |
|---|---|---|---|
imageBase64 | string | Yes | Base64-encoded image without the data:image/… prefix. Maximum 10 MB decoded |
redactPii | boolean | No | Redact detected PII in the image. Default true |
confidenceThreshold | number | No | Minimum detection confidence, 0–1. Default 0.5 |
language | string | No | OCR language hint, for example en or tr. Default auto |
ocrEngine | string | No | paddleocr or tesseract. Default paddleocr |
sessionId | string | No | Log the detections against this session |
The size limit is checked on the encoded string as length × 3 / 4, so a request whose decoded
image exceeds 10 MB is rejected by validation with Image size exceeds maximum allowed size of 10MB before any OCR runs. Base64 inflates a payload by about a third, so a 10 MB image arrives as
roughly 13.3 MB of JSON.
Response
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the analysis completed |
action | string | allow, mask, reject or flag |
extractedText | string | The OCR output the detectors ran over |
piiDetections | array | {type, value, confidence, action, boundingBoxes?} |
safetyDetections | array | {type, confidence, action} |
summary | object | {piiCount, safetyIssueCount} |
wasRedacted | boolean | Whether a redacted image was produced |
redactedImageBase64 | string | Present only when wasRedacted is true |
processingTimeMs | number | Wall time for the whole call |
actionReason, rejectionReason | string | Why the action was chosen, when there is one to give |
documentType | object | {type, confidence, signals} from the rule-based document classifier |
mrzDetected | boolean | Whether a passport machine-readable zone was parsed |
ocrFailed | boolean | Set when OCR produced nothing usable |
Redaction is selective and follows the action each filter decided: entities set to mask are painted
out of the image, entities set to flag are recorded but left visible, and a reject blocks the whole
image. extractedText and the detection arrays are always returned; redactedImageBase64 appears
only when something was actually masked.
Note
The image path runs two detectors the text path does not: an ICAO 9303 MRZ parser
(source: "mrz") and an identity-document layout extractor (source: "identity_layout"). An
image classified as an identity document skips jailbreak detection.
List OCR engines
GET /image-analysis/ocr-engines
Returns the OCR engines the deployment can use and their language support. No request body.
Compare OCR engines
POST /image-analysis/compare-ocr
Runs one image through several engines so you can compare extraction quality.
| Parameter | Type | Required | Description |
|---|---|---|---|
imageBase64 | string | Yes | Base64-encoded image, same 10 MB limit |
language | string | No | Language hint. Default auto |
engines | string[] | No | Engines to compare. Default: all available |
confidenceThreshold | number | No | 0–1. Default 0.5 |
Related
- Document analysis — the same pipeline over PDF, DOCX, TXT, CSV and XLSX.
- PII detection — which entity types the OCR text is scanned for.
- Content detection — the detection contract these responses share.
Last updated on