Run OCR on a document or image
POST /v1/ocr:document: Runs layout-aware OCR on the provided document bytes and returns per-page results.
Runs layout-aware OCR on the provided document bytes and returns per-page results. When a page range is provided, only the inclusive subset is processed. Requires OCR_DOCUMENT permission.
ApiKeyAuthx-api-key<token>GoodMem-Timeout-Ms?integerOptional waiting budget in milliseconds, measured from REST servlet ingress and shared across all internal gRPC calls. Supply one decimal integer from 1 to 86400000. Omission adds no deadline. Existing shorter deadlines still apply. Expiry returns HTTP 504 before streaming starts; after streaming starts, no successful completion event is sent. Use SSE or opt into GoodMem-Stream-Terminal for an explicit terminal outcome. Retrieval work is cooperatively cancelled. An accepted mutation may still commit after timeout or disconnect; a failed response does not imply rollback.
int641 <= value <= 86400000OCR request payload
application/json- body
Request body for OCR document processing.
content*|Base64-encoded document bytes
"JVBERi0xLjQKJcTl8uXr..."format?|Input format hint (AUTO, PDF, TIFF, PNG, JPEG, BMP)
"PDF"includeRawJson?|Include raw OCR JSON payload in the response
trueincludeMarkdown?|Include markdown rendering in the response
truestartPage?|0-based inclusive start page
int320 <= value0endPage?|0-based inclusive end page
int320 <= value4OCR results by page
application/json- response
Response containing page-ordered OCR results.
detectedFormat*OcrInputFormatDetected input format
"PDF""AUTO""PDF""TIFF""PNG""JPEG""BMP"pageCount*integerNumber of pages processed after applying the range
int320 <= value12pages*array<>Ordered per-page OCR results
timings*Aggregate timing statistics
curl -X POST 'https://your-goodmem-server.example.com/v1/ocr:document' \ -H 'GoodMem-Timeout-Ms: 30000' \ -H 'Content-Type: application/json' \ -d '{ "content": "JVBERi0xLjQKJcTl8uXr...", "format": "PDF", "includeRawJson": true, "includeMarkdown": true, "startPage": 0, "endPage": 4}'{ "detectedFormat": "PDF", "pageCount": 12, "pages": [ { "pageIndex": 0, "page": { "rawJson": "[{\"text\":\"Example\"}]", "markdown": "# Heading", "timings": { "queueWaitMs": 15, "renderMs": 42, "ocrMs": 118, "totalMs": 175 }, "image": { "widthPx": 2150, "heightPx": 2575, "dpi": 200 } }, "status": { "code": 13, "message": "OCR request failed for page 3" } } ], "timings": { "wallTimeMs": 14324, "sumQueueWaitMs": 3959255, "sumRenderMs": 14005, "sumOcrMs": 50987, "sumPageTotalMs": 4024248 }}