GoodMemGoodMem
ReferenceAPIREST APIOCR

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.

POST
/v1/ocr:document

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.

Authorization

ApiKeyAuth
headerx-api-key<token>

Header Parameters

GoodMem-Timeout-Ms?integer

Optional 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.

Formatint64
Range1 <= value <= 86400000

Request Body

OCR request payload

application/json
  1. body

Request body for OCR document processing.

content*|

Base64-encoded document bytes

Example"JVBERi0xLjQKJcTl8uXr..."
format?|

Input format hint (AUTO, PDF, TIFF, PNG, JPEG, BMP)

Example"PDF"
includeRawJson?|

Include raw OCR JSON payload in the response

Exampletrue
includeMarkdown?|

Include markdown rendering in the response

Exampletrue
startPage?|

0-based inclusive start page

Formatint32
Range0 <= value
Example0
endPage?|

0-based inclusive end page

Formatint32
Range0 <= value
Example4

Response Body

OCR results by page

application/json
  1. response

Response containing page-ordered OCR results.

detectedFormat*OcrInputFormat

Detected input format

Example"PDF"
Value in"AUTO""PDF""TIFF""PNG""JPEG""BMP"
pageCount*integer

Number of pages processed after applying the range

Formatint32
Range0 <= value
Example12
pages*array<>

Ordered per-page OCR results

timings*

Aggregate timing statistics

Example Request
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}'
Example Response
{  "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  }}