API reference — Sarvam Vision
API reference — Sarvam Vision
The contract for invoking a self-hosted Sarvam Vision endpoint. You send the raw document bytes as the request body and pass options as custom attributes.
InvokeEndpoint
Supported content types
An omitted type, application/octet-stream, or text/plain is treated as PDF and the bytes are sniffed. A Content-Type that doesn’t match the bytes is rejected with 400 INVALID_INPUT.
TIFF, WebP, BMP, and GIF are not supported — they’re rejected with 415 UNSUPPORTED_MEDIA_TYPE. Convert to PNG, JPEG, or PDF first.
Limits
Options — custom attributes
Pass options in the X-Amzn-SageMaker-Custom-Attributes header (sync) or the CustomAttributes parameter (async), as key=value,key=value or a JSON object.
Response
The default response is a JSON envelope (Content-Type: application/json):
With output_format=json, result.pages[] is added — per page page_num, width, height, unit, origin, and blocks[] with id, type (layout tag), reading_order, bbox, text, layout_confidence, and ocr_confidence.
Set output=zip (or send Accept: application/zip) to get a zip bundle instead: the merged document at the root ({name}.md / .html, always present) plus metadata/page_NNN.json per page.
The response header X-Amzn-SageMaker-Custom-Attributes echoes job_id, schema_version, and api_version. Log the job_id — support can trace any request with it.
The sync endpoint is for small documents (up to 5 pages) at low concurrency. It must finish inside AWS’s 60-second timeout, so keep sync requests to 5 pages or fewer and, on the recommended single-GPU instance (ml.g6e.xlarge), only 1–2 documents in flight or requests will time out. For anything larger than 5 pages, higher concurrency, or bulk work, use an async endpoint or batch transform — see Deploy Sarvam Vision.
Errors
Every non-2xx is delivered as HTTP 424 through InvokeEndpoint — branch on OriginalStatusCode plus error.code / error.detail_code, never on the HTTP status. See Error handling on SageMaker for the collapse rule and the shared envelope.
Errors always come back as the same JSON envelope — never HTML, never a bare string. The error envelope uses schema_version: "2.0" (a successful response is "1.0" — a known inconsistency). error carries code (the class), detail_code (the specific reason), message, retryable, and request_id — plus retry_after on an overload 503:
Client errors — fix the request, don’t retry
error.code is invalid_request_error and retryable is false; the error.detail_code names the specific reason.
Overload — back off and retry
error.code is service_overloaded, retryable is true, and the body carries retry_after (seconds). The container sheds immediately rather than queueing.
Other server errors — retryable
retryable is true; back off and retry, and report error.request_id if one file fails persistently.
Rule of thumb: 4xx = fix the request; 5xx = retry with backoff. The retryable flag in every error body encodes exactly this.