Stratus API
Detect regions on a page, inspect them, then read the parts that matter.
Start at /v1/stratus/capabilities and check whether pipeline.available is true. The first qualified whole-job pair is PP-DocLayout-v3 detection and Mistral OCR 4.1 reading. It is useful for dense tables, multi-column ledgers, and pages where ordinary OCR loses the relationship between values and their source regions. Read the live offer before quoting; availability can change while the detector starts.
Before you begin
Use a write-capable OpenOCR API key (sk-ocr-...) and enable OCR history for durable jobs in Dashboard → Settings → OCR history by choosing Turn on history. See history retention and result recovery for details. These examples upload two PNG pages in document order and select all detected regions. Change SOURCE_FILES to your own page paths. Install curl, jq, and Python 3 locally. Keep the same idempotency_key when retrying an acceptance or selection after a lost response; use a new key for a different request. The Stratus keys are JSON fields, while /v1/ocr uses an Idempotency-Key header.
Save the walkthrough blocks in one Bash script and run it with bash walkthrough.sh, or run them inside a subshell (enter ( before the first block and ) after the last). Keep the blocks in the same script or subshell so variables and helper functions carry across steps. The walkthrough uses set -euo pipefail, and its polling code calls exit on failure. Pasting these commands directly into an interactive shell can close your terminal and lose variables such as JOB_ID.
set -euo pipefail
export BASE_URL="https://api.open-ocr.com"
export OPENOCR_API_KEY="sk-ocr-..."
# Put the PNG pages in document order. Each becomes a logical source page.
SOURCE_FILES=("./page-1.png" "./page-2.png")The JSON bodies below use saved two-page client responses and a deterministic router result fixture; IDs and timestamps are illustrative. Copy the shell commands to obtain your own live values. The full retained stage and result examples show the complete wire shape, including fields that are null before work finishes.
1. Check capabilities
This read has no JSON request body. Check pipeline.available and use the offered engine IDs, revisions, limits and prices. If reason is pipeline_starting, wait for retry_after_seconds (about 30 seconds) and check again. Older routers can report a wake as no_qualified_pipeline even on the first call; the helper waits 30 seconds and retries that capabilities response at most twice before failing. This reason can also mean no qualified pipeline is available. The helper makes at most five calls in total, honors retry_after_seconds for pipeline_starting, and fails with the response if unavailability persists. A quote attempted during startup returns 503 pipeline_starting with a Retry-After header. The offer's expires_at is a short health window, so fetch a fresh one before a delayed quote.
# Retry detector startup, at most five calls (two legacy wake retries).
pipeline_request() {
local method="$1" path="$2" body="$3" mode="$4"
local attempt response status payload reason delay
local legacy_retries=0
local -a data_args=()
if [ "$method" != GET ]; then
data_args=(-H 'Content-Type: application/json' -d "$body")
fi
for attempt in $(seq 1 5); do
response="$(curl -sS -X "$method" "$BASE_URL$path" \
-H "Authorization: Bearer $OPENOCR_API_KEY" \
"${data_args[@]}" \
-w '\n%{http_code}')" || return 1
status="$(printf '%s\n' "$response" | tail -n 1)"
payload="$(printf '%s\n' "$response" | sed '$d')"
if [ "$status" = 200 ]; then
if [ "$mode" != capabilities ] || printf '%s\n' "$payload" | \
jq -e '.pipeline.available == true and (.pipeline.offers | length > 0)' >/dev/null; then
printf '%s\n' "$payload"; return 0
fi
reason="$(printf '%s\n' "$payload" | jq -r '.pipeline.reason // "unavailable"')"
elif [ "$status" = 503 ]; then
reason="$(printf '%s\n' "$payload" | jq -r '.error.code // "unavailable"')"
else
printf 'Pipeline request failed (HTTP %s): %s\n' "$status" "$payload" >&2
return 1
fi
if [ "$reason" = pipeline_starting ] && [ "$attempt" -lt 5 ]; then
delay="$(printf '%s\n' "$payload" | jq -r \
'.pipeline.retry_after_seconds // .retry_after_seconds // 30')"
elif [ "$mode" = capabilities ] && [ "$status" = 200 ] && \
[ "$reason" = no_qualified_pipeline ] && [ "$legacy_retries" -lt 2 ] && [ "$attempt" -lt 5 ]; then
legacy_retries=$((legacy_retries + 1))
delay=30
else
printf 'Pipeline request failed after %s call(s) (HTTP %s, %s): %s\n' \
"$attempt" "$status" "$reason" "$payload" >&2
return 1
fi
printf 'Pipeline unavailable (%s); retrying in %s seconds (%s/5).\n' "$reason" "$delay" "$attempt" >&2
sleep "$delay"
done
}
CAPABILITIES="$(pipeline_request GET /v1/stratus/capabilities '' capabilities)"
echo "$CAPABILITIES" | jq '.pipeline'
OFFER="$(echo "$CAPABILITIES" | jq -c '.pipeline.offers[0]')"Complete request and response example
JSON response body
{
"document_context": false,
"native_layout_enabled": false,
"native_readers": [],
"pipeline": {
"available": true,
"next_action": null,
"offers": [
{
"billing": {
"reader_customer_per_attempt_micros": 4000,
"stage_customer_per_attempt_micros": 3000,
"unit": "micro_usd"
},
"expires_at": "2026-10-30T04:55:55.951893878Z",
"limits": {
"max_raster_bytes_per_page": 10485760,
"max_reader_attempts": 1,
"max_regions": 16,
"max_source_pages": 4,
"max_stage_attempts": 1,
"max_total_pixels": 25000000,
"raster_mime_types": [
"image/png",
"image/jpeg"
],
"supports_pdf_raster_proof": true
},
"qualification_sha256": "089a46495dc9d99edede0e58843b0b8beda5bf56cb18001db73a46222ffc9e3c",
"reader": {
"document_context": false,
"engine_id": "mistral-mistral-ocr-4-1",
"model_revision": "mistral-ocr-4-1",
"transcription": false
},
"segmentation": {
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6"
}
}
],
"reason": null,
"schema_version": 1
},
"readers": [
{
"customer_per_attempt_micros": 4000,
"engine_id": "mistral-mistral-ocr-4-1",
"model_revision": "mistral-ocr-4-1",
"name": "Mistral OCR 4.1",
"provider_per_attempt_micros": 4000,
"recipient_provider": "mistral"
}
],
"schema_version": 1,
"source_mime_types": [
"image/png",
"image/jpeg",
"application/pdf"
],
"transcription": false
}2. Upload source pages
Create a draft Workbench batch with {}, then POST the raw PNG or JPEG bytes to /v1/workbench/batches/{id}/files. Set Content-Type to image/png or image/jpeg and send X-Filename. The upload response's id is the Stratus source_item_id. An image upload is already a raster; do not call the PDF render route for it. raster_sha256 is the lowercase SHA-256 of the exact uploaded image bytes, before any decoding or crop. The job rechecks those stored bytes.
BATCH_RESPONSE="$(curl -fsS -X POST "$BASE_URL/v1/workbench/batches" \
-H "Authorization: Bearer $OPENOCR_API_KEY" \
-H 'Content-Type: application/json' -d '{}')"
BATCH_ID="$(echo "$BATCH_RESPONSE" | jq -r '.id')"
SOURCES='[]'
PAGE_NUMBER=0
for SOURCE_FILE in "${SOURCE_FILES[@]}"; do
PAGE_NUMBER=$((PAGE_NUMBER + 1))
read WIDTH HEIGHT < <(python3 - "$SOURCE_FILE" <<'PY'
import struct, sys
with open(sys.argv[1], 'rb') as image:
header = image.read(24)
if header[:8] != b'\x89PNG\r\n\x1a\n' or header[12:16] != b'IHDR':
raise SystemExit('Expected a PNG file')
print(*struct.unpack('>II', header[16:24]))
PY
)
RASTER_SHA256="$(sha256sum "$SOURCE_FILE" | cut -d' ' -f1)"
UPLOAD_RESPONSE="$(curl -fsS -X POST "$BASE_URL/v1/workbench/batches/$BATCH_ID/files" \
-H "Authorization: Bearer $OPENOCR_API_KEY" \
-H 'Content-Type: image/png' -H "X-Filename: $(basename "$SOURCE_FILE")" \
--data-binary @"$SOURCE_FILE")"
echo "$UPLOAD_RESPONSE" | jq -e '.status == "uploaded" and .page_count == 1' >/dev/null
SOURCES="$(jq -cn --argjson sources "$SOURCES" \
--arg item "$(echo "$UPLOAD_RESPONSE" | jq -r '.id')" --arg sha "$RASTER_SHA256" \
--argjson page "$PAGE_NUMBER" --argjson width "$WIDTH" --argjson height "$HEIGHT" \
'$sources + [{source_item_id:$item, raster_sha256:$sha, page_number:$page,
width:$width, height:$height, pdf:null}]')"
done
echo "$SOURCES" | jq .Complete request and response example
POST /v1/workbench/batches
JSON request body
{}JSON response body
{
"id": "91f3c13d-d4e7-4526-b88c-a7906894c84e",
"name": "Untitled batch",
"status": "draft",
"pause_reason": null,
"settings": {},
"settings_version": 0,
"estimated_cost": null,
"created_at": "2026-10-30T04:55:30.623Z",
"updated_at": "2026-10-30T04:55:30.623Z",
"started_at": null,
"finished_at": null,
"deleted_at": null,
"counts": {
"files": 0,
"pages": 0,
"uploaded": 0,
"skipped": 0,
"queued": 0,
"held": 0,
"running": 0,
"done": 0,
"failed": 0,
"cancelled": 0,
"pages_done": 0,
"originals": 0
},
"cost": 0,
"originals_expire_at": null,
"eta_seconds": null
}Image upload HTTP request
{
"method": "POST",
"path": "/v1/workbench/batches/91f3c13d-d4e7-4526-b88c-a7906894c84e/files",
"headers": {
"Authorization": "Bearer $OPENOCR_API_KEY",
"Content-Type": "image/png",
"X-Filename": "page-1.png"
},
"body": "<raw bytes of page-1.png>"
}This describes the HTTP request. Its body is raw image bytes, not a JSON object.
Complete request and response example
The upload request body is the exact PNG/JPEG file bytes sent with --data-binary. The response below is a complete Workbench item.
JSON response body
{
"id": "507c3d01-2dbd-466e-b039-5dfcaf09c08b",
"batch_id": "91f3c13d-d4e7-4526-b88c-a7906894c84e",
"batch_name": "Untitled batch",
"position": 0,
"filename": "page-1.png",
"relative_path": null,
"mime_type": "image/png",
"size_bytes": 300716,
"page_count": 1,
"status": "uploaded",
"skip_reason": null,
"attempt": 0,
"engine_id": null,
"pages_done": 0,
"cost": 0,
"total_charged": 0,
"error_code": null,
"error_message": null,
"text_preview": null,
"has_original": true,
"originals_expire_at": null,
"edited": false,
"created_at": "2026-10-30T04:55:32.645Z",
"started_at": null,
"finished_at": null,
"next_retry_at": null,
"unread_pages": [],
"client_upload_id": null
}For a PDF, upload the original to a batch with Content-Type: application/pdf, then render its selected pages. Build each quote source by copying exactly source_item_id, raster_sha256, page_number, width, height, and pdf from the returned source_page; omit display. Its raster_sha256 covers the rendered image bytes returned as image_base64, while pdf.source_sha256 covers the original uploaded PDF. The proof ties the raster to the original page and renderer; the PDF bytes are not sent to the detector.
# Optional alternative: replace the PNG SOURCES array with rendered PDF pages.
PDF_FILE="./source.pdf"
PDF_UPLOAD_RESPONSE="$(curl -fsS -X POST "$BASE_URL/v1/workbench/batches/$BATCH_ID/files" \
-H "Authorization: Bearer $OPENOCR_API_KEY" \
-H 'Content-Type: application/pdf' -H "X-Filename: $(basename "$PDF_FILE")" \
--data-binary @"$PDF_FILE")"
PDF_SOURCE_ITEM_ID="$(echo "$PDF_UPLOAD_RESPONSE" | jq -r '.id')"
PDF_RENDER_REQUEST='{"page_numbers":[1,2]}'
PDF_RENDER_RESPONSE="$(curl -fsS -X POST "$BASE_URL/v1/stratus/sources/$PDF_SOURCE_ITEM_ID/render" \
-H "Authorization: Bearer $OPENOCR_API_KEY" \
-H 'Content-Type: application/json' -d "$PDF_RENDER_REQUEST")"
# Logical page numbers are 1..N in document order; pdf.source_page_number
# retains the original PDF page number. Keep each page's own pdf proof.
SOURCES="$(echo "$PDF_RENDER_RESPONSE" | jq -c '[.pages[].source_page] |
to_entries | map(.value + {page_number:(.key + 1)} |
{source_item_id, raster_sha256, page_number, width, height, pdf})')"
echo "$SOURCES" | jq .Complete request and response example
Optional PDF render exchange. The small raster and IDs illustrate the route's complete JSON shape; use the response returned for your own uploaded PDF.
JSON request body
{
"page_numbers": [
1,
2
]
}JSON response body
{
"schema_version": 1,
"source_item_id": "33333333-3333-4333-8333-333333333333",
"source_pdf_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"total_pages": 2,
"pages": [
{
"source_page": {
"page_number": 1,
"source_item_id": "33333333-3333-4333-8333-333333333333",
"raster_sha256": "b0e8a8eb92c36f8866407013c607f13127ae9f48b7f6750f236851d23426664d",
"width": 1,
"height": 1,
"display": {
"rotation_degrees": 0,
"scale": 1,
"width": 1,
"height": 1,
"original_to_display": [
1,
0,
0,
1,
0,
0
]
},
"pdf": {
"source_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"source_page_number": 1,
"renderer_id": "openocr-pdf-preprocessor/v1;fixture",
"render_dpi": 200,
"render_max_long_side": 4500,
"render_max_pixels": 16000000,
"render_max_total_pixels": 25000000,
"effective_dpi": 200
}
},
"warning": null,
"image_base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4z8DwHwAFgAI/ScL/nwAAAABJRU5ErkJggg=="
},
{
"source_page": {
"page_number": 2,
"source_item_id": "33333333-3333-4333-8333-333333333333",
"raster_sha256": "b0e8a8eb92c36f8866407013c607f13127ae9f48b7f6750f236851d23426664d",
"width": 1,
"height": 1,
"display": {
"rotation_degrees": 0,
"scale": 1,
"width": 1,
"height": 1,
"original_to_display": [
1,
0,
0,
1,
0,
0
]
},
"pdf": {
"source_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"source_page_number": 2,
"renderer_id": "openocr-pdf-preprocessor/v1;fixture",
"render_dpi": 200,
"render_max_long_side": 4500,
"render_max_pixels": 16000000,
"render_max_total_pixels": 25000000,
"effective_dpi": 200
}
},
"warning": null,
"image_base64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIHWP4z8DwHwAFgAI/ScL/nwAAAABJRU5ErkJggg=="
}
]
}PDF quote source projection
[
{
"source_item_id": "33333333-3333-4333-8333-333333333333",
"raster_sha256": "b0e8a8eb92c36f8866407013c607f13127ae9f48b7f6750f236851d23426664d",
"page_number": 1,
"width": 1,
"height": 1,
"pdf": {
"source_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"source_page_number": 1,
"renderer_id": "openocr-pdf-preprocessor/v1;fixture",
"render_dpi": 200,
"render_max_long_side": 4500,
"render_max_pixels": 16000000,
"render_max_total_pixels": 25000000,
"effective_dpi": 200
}
},
{
"source_item_id": "33333333-3333-4333-8333-333333333333",
"raster_sha256": "b0e8a8eb92c36f8866407013c607f13127ae9f48b7f6750f236851d23426664d",
"page_number": 2,
"width": 1,
"height": 1,
"pdf": {
"source_sha256": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"source_page_number": 2,
"renderer_id": "openocr-pdf-preprocessor/v1;fixture",
"render_dpi": 200,
"render_max_long_side": 4500,
"render_max_pixels": 16000000,
"render_max_total_pixels": 25000000,
"effective_dpi": 200
}
}
]For a PDF job, use this projected array as the quote request's sources and accept the quote returned for that request. In the later selection plan, keep the accepted source's pdf proof alongside the page display fields.
3. Quote the whole job
POST /v1/stratus/pipeline/quotes. account_id is optional and is derived from the API key. If supplied, it must match the caller or the API returns 422 pipeline_account_mismatch. The source proof uses a logical page_number starting at 1. effective_controls is the exact caller context and transcription settings bound into the quote. It accepts document_context (type or description) and transcription (plain_text or markdown format, or instructions); use {} for none. This first offered pair reports both controls unsupported, so send {}.
# Refresh the short-lived offer after uploading.
CAPABILITIES="$(pipeline_request GET /v1/stratus/capabilities '' capabilities)"
OFFER="$(echo "$CAPABILITIES" | jq -c '.pipeline.offers[0]')"
# Choose the largest number of reads you are willing to fund before detection.
MAX_REGIONS="$(echo "$OFFER" | jq -r '.limits.max_regions')"
QUOTE_REQUEST="$(jq -n --argjson sources "$SOURCES" \
--argjson max_regions "$MAX_REGIONS" --argjson offer "$OFFER" '{
sources:$sources,
segmentation_engine_id:$offer.segmentation.engine_id,
segmentation_revision:$offer.segmentation.model_revision,
reader_engine_id:$offer.reader.engine_id,
reader_revision:$offer.reader.model_revision,
max_stage_attempts:1, max_regions:$max_regions, max_reader_attempts:1,
effective_controls:{}
}')"
QUOTE_RESPONSE="$(pipeline_request POST /v1/stratus/pipeline/quotes "$QUOTE_REQUEST" quote)"
echo "$QUOTE_RESPONSE" | jq '{quote_id:.quote.quote_id, customer_ceiling_micros:.quote.customer_ceiling_micros, expires_at:.quote.window.expires_at}'Complete request and response example
The request uses the qualified pair offered to your account. The response has the complete router quote shape from the two-page client run; IDs, timestamps and prices are illustrative. Copy your own live quote object unchanged into acceptance.
JSON request body
{
"sources": [
{
"height": 796,
"page_number": 1,
"pdf": null,
"raster_sha256": "24d80ba381884019312ccfa76b448e2220b1b625a17a51f233468d7ef3b20bc9",
"source_item_id": "507c3d01-2dbd-466e-b039-5dfcaf09c08b",
"width": 1380
},
{
"height": 796,
"page_number": 2,
"pdf": null,
"raster_sha256": "789b0e0e40231d95bf9adfdb491e03d940816fa57d705af94a3806cf5f7557d3",
"source_item_id": "74a95fb6-781a-45e7-a352-2eeb81841ff5",
"width": 1380
}
],
"segmentation_engine_id": "pp-doclayout-v3",
"segmentation_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"reader_engine_id": "mistral-mistral-ocr-4-1",
"reader_revision": "mistral-ocr-4-1",
"max_stage_attempts": 1,
"max_regions": 16,
"max_reader_attempts": 1,
"effective_controls": {}
}JSON response body
{
"note": "The quote covers the full accepted segmentation and regional reading ceiling.",
"quote": {
"customer_ceiling_micros": 70000,
"private_identity": {
"algorithm": "hmac-sha256",
"digest": "c91a5e7a9bc41778eff2ee7ef87eb5f7bc95636302b4d3fca57f03e6a92625f9",
"key_version": "stg1"
},
"provider_ceiling_micros": 64000,
"qualification_sha256": "089a46495dc9d99edede0e58843b0b8beda5bf56cb18001db73a46222ffc9e3c",
"quote_id": "6e0e592f-357c-4276-8067-94785293980f",
"reader_customer_per_attempt_micros": 4000,
"reader_provider_per_attempt_micros": 4000,
"stage_cost_basis": "self_hosted_external_fee_zero",
"stage_customer_per_attempt_micros": 3000,
"stage_provider_per_attempt_micros": 0,
"tariff_version": "prod-release2-v2-stage3000",
"window": {
"expires_at": "2026-10-30T05:05:43.978543Z",
"issued_at": "2026-10-30T04:55:43.978543Z",
"job_deadline_at": "2026-10-30T05:55:43.978543Z"
}
},
"schema_version": 1,
"source_page_count": 2
}max_regions is the maximum number of selected regions across the entire job, not per page. The quote ceiling is stage price × source pages × stage attempts + reader price × selected-region limit × reader attempts. Amounts ending in _micros are integer micro-USD: 1,000,000 micro-USD = $1.
Choose max_regions before detection as the most regions you are willing to pay to read. This example uses the offer limit (currently 16) because the detected count is not known yet; choose a smaller cap to limit the hold, but you can then select only that many regions. Acceptance holds the quoted ceiling. Detection attempts are charged as they run; only the selected regional reads that run are charged, and unused funds are released.
In this two-page example, 16 possible reads produce a $0.070 quote and hold; detection finds seven regions, all seven are read, and the final charge is $0.034 ($0.006 detection + $0.028 reading). The remaining $0.036 is released. These are illustrative prices, not a price guarantee: read current prices from capabilities.pipeline.offers[0].billing and your returned quote.
The capability offer is refreshed on a roughly 30-second health window. A quote has a separate window.expires_at (currently 10 minutes after issue); accept promptly or re-quote after pipeline_quote_expired.
4. Accept the quote
POST the same request and the returned quote to /v1/stratus/pipeline/jobs, with a stable JSON idempotency_key. Acceptance places a hold for the quoted ceiling and returns a job_id. The same bounded helper retries 503 pipeline_starting, honoring retry_after_seconds and reusing the exact acceptance body and key. That startup response places no hold. If the quote expires while waiting, fetch a fresh quote before accepting again. If 422 pipeline_job_exists names a running job, open that job rather than submitting another.
ACCEPT_REQUEST="$(jq -n --argjson request "$QUOTE_REQUEST" \
--argjson quote "$(echo "$QUOTE_RESPONSE" | jq '.quote')" \
--arg key "$(python3 -c 'import uuid; print(uuid.uuid4())')" \
'{request:$request, quote:$quote, idempotency_key:$key}')"
# The helper retries 503 pipeline_starting with this exact body and key.
ACCEPT_RESPONSE="$(pipeline_request POST /v1/stratus/pipeline/jobs "$ACCEPT_REQUEST" accept)"
JOB_ID="$(echo "$ACCEPT_RESPONSE" | jq -r '.job_id')"
echo "$ACCEPT_RESPONSE" | jq .Complete request and response example
The body and response show the complete route-contract shape; fixture IDs and charges are illustrative.
JSON request body
{
"request": {
"sources": [
{
"height": 796,
"page_number": 1,
"pdf": null,
"raster_sha256": "24d80ba381884019312ccfa76b448e2220b1b625a17a51f233468d7ef3b20bc9",
"source_item_id": "507c3d01-2dbd-466e-b039-5dfcaf09c08b",
"width": 1380
},
{
"height": 796,
"page_number": 2,
"pdf": null,
"raster_sha256": "789b0e0e40231d95bf9adfdb491e03d940816fa57d705af94a3806cf5f7557d3",
"source_item_id": "74a95fb6-781a-45e7-a352-2eeb81841ff5",
"width": 1380
}
],
"segmentation_engine_id": "pp-doclayout-v3",
"segmentation_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"reader_engine_id": "mistral-mistral-ocr-4-1",
"reader_revision": "mistral-ocr-4-1",
"max_stage_attempts": 1,
"max_regions": 16,
"max_reader_attempts": 1,
"effective_controls": {}
},
"quote": {
"customer_ceiling_micros": 70000,
"private_identity": {
"algorithm": "hmac-sha256",
"digest": "c91a5e7a9bc41778eff2ee7ef87eb5f7bc95636302b4d3fca57f03e6a92625f9",
"key_version": "stg1"
},
"provider_ceiling_micros": 64000,
"qualification_sha256": "089a46495dc9d99edede0e58843b0b8beda5bf56cb18001db73a46222ffc9e3c",
"quote_id": "6e0e592f-357c-4276-8067-94785293980f",
"reader_customer_per_attempt_micros": 4000,
"reader_provider_per_attempt_micros": 4000,
"stage_cost_basis": "self_hosted_external_fee_zero",
"stage_customer_per_attempt_micros": 3000,
"stage_provider_per_attempt_micros": 0,
"tariff_version": "prod-release2-v2-stage3000",
"window": {
"expires_at": "2026-10-30T05:05:43.978543Z",
"issued_at": "2026-10-30T04:55:43.978543Z",
"job_deadline_at": "2026-10-30T05:55:43.978543Z"
}
},
"idempotency_key": "accept-first"
}JSON response body
{
"billing": {
"accepted_customer_ceiling_micros": 70000,
"held_remaining_micros": 70000,
"unit": "micro_usd"
},
"job_id": "97ecdd70-3786-41bf-84fb-f0e0ba574433",
"job_kind": "pipeline_segmentation",
"replayed": false,
"schema_version": 1,
"source_page_count": 2,
"state": "queued"
}5. Watch detection stages
GET /v1/stratus/jobs/{job_id}/stages until stage_state is awaiting_selection. Read each settled attempt's result.segmentation_result.regions, its page number and boxes. A stage can fail; inspect status and error_code instead of assuming a region list.
# Poll until detection is financially settled and selection is available.
for attempt in $(seq 1 60); do
STAGES="$(curl -fsS "$BASE_URL/v1/stratus/jobs/$JOB_ID/stages" \
-H "Authorization: Bearer $OPENOCR_API_KEY")"
echo "$STAGES" | jq '{state, stage_state, regions:[.attempts[].result.segmentation_result.regions[]?.id]}'
[ "$(echo "$STAGES" | jq -r '.stage_state')" = awaiting_selection ] && break
if echo "$STAGES" | jq -e 'any(.attempts[]; .status == "failed" or .status == "cancelled")' >/dev/null; then
echo 'Detection did not complete; inspect STAGES.' >&2; exit 1
fi
sleep 2
done
[ "$(echo "$STAGES" | jq -r '.stage_state')" = awaiting_selection ]Complete request and response example
Complete two-page retained-stage response from the successful round 3 client run.
JSON response body
{
"accepted_request": {
"account_id": "e9bc1925-4940-4fef-8da7-7d6f07a3e3a8",
"effective_controls": {},
"max_reader_attempts": 1,
"max_regions": 16,
"max_stage_attempts": 1,
"reader_engine_id": "mistral-mistral-ocr-4-1",
"reader_revision": "mistral-ocr-4-1",
"segmentation_engine_id": "pp-doclayout-v3",
"segmentation_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"sources": [
{
"height": 796,
"page_number": 1,
"pdf": null,
"raster_sha256": "24d80ba381884019312ccfa76b448e2220b1b625a17a51f233468d7ef3b20bc9",
"source_item_id": "507c3d01-2dbd-466e-b039-5dfcaf09c08b",
"width": 1380
},
{
"height": 796,
"page_number": 2,
"pdf": null,
"raster_sha256": "789b0e0e40231d95bf9adfdb491e03d940816fa57d705af94a3806cf5f7557d3",
"source_item_id": "74a95fb6-781a-45e7-a352-2eeb81841ff5",
"width": 1380
}
]
},
"attempts": [
{
"attempt_number": 1,
"completed_at": "2026-10-30T04:56:04.605301Z",
"customer_charge_micros": 3000,
"dispatch_started_at": "2026-10-30T04:55:56.676436Z",
"error_code": null,
"financially_settled": true,
"page_number": 1,
"result": {
"evidence_kind": "bridge_observed",
"logical_page_number": 1,
"provider_region_ids": {
"page-1:id-r001": "r001",
"page-1:id-r002": "r002",
"page-1:id-r003": "r003",
"page-1:id-r004": "r004",
"page-1:id-r005": "r005"
},
"provider_source_page_number": 1,
"schema_version": 1,
"segmentation_result": {
"elapsed_ms": 5645,
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"regions": [
{
"bbox": [
589,
26,
822,
57
],
"confidence": 0.5932497382164001,
"id": "page-1:id-r001",
"label": "header",
"reading_order": null
},
{
"bbox": [
120,
72,
1324,
580
],
"confidence": 0.8993438482284546,
"id": "page-1:id-r002",
"label": "table",
"reading_order": null
},
{
"bbox": [
194,
595,
712,
631
],
"confidence": 0.740493655204773,
"id": "page-1:id-r003",
"label": "vision_footnote",
"reading_order": null
},
{
"bbox": [
1022,
607,
1258,
644
],
"confidence": 0.5386931300163269,
"id": "page-1:id-r004",
"label": "footer",
"reading_order": null
},
{
"bbox": [
1320,
25,
1350,
119
],
"confidence": 0.5441786050796509,
"id": "page-1:id-r005",
"label": "aside_text",
"reading_order": null
}
],
"schema_version": 1,
"source": {
"height": 796,
"page": 1,
"sha256": "24d80ba381884019312ccfa76b448e2220b1b625a17a51f233468d7ef3b20bc9",
"width": 1380
},
"threshold": 0.5,
"warnings": [
"Table regions are boxes only; no rows, cells, or text were reconstructed"
]
}
},
"result_validated": true,
"stage_attempt_id": "bea9295f-13c2-49d0-910c-29c48c7e0b09",
"status": "succeeded"
},
{
"attempt_number": 1,
"completed_at": "2026-10-30T04:56:17.532403Z",
"customer_charge_micros": 3000,
"dispatch_started_at": "2026-10-30T04:56:12.080580Z",
"error_code": null,
"financially_settled": true,
"page_number": 2,
"result": {
"evidence_kind": "bridge_observed",
"logical_page_number": 2,
"provider_region_ids": {
"page-2:id-r001": "r001",
"page-2:id-r002": "r002"
},
"provider_source_page_number": 1,
"schema_version": 1,
"segmentation_result": {
"elapsed_ms": 4995,
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"regions": [
{
"bbox": [
117,
38,
1289,
104
],
"confidence": 0.8004903793334961,
"id": "page-2:id-r001",
"label": "figure_title",
"reading_order": null
},
{
"bbox": [
121,
92,
1354,
771
],
"confidence": 0.9398114681243896,
"id": "page-2:id-r002",
"label": "table",
"reading_order": null
}
],
"schema_version": 1,
"source": {
"height": 796,
"page": 2,
"sha256": "789b0e0e40231d95bf9adfdb491e03d940816fa57d705af94a3806cf5f7557d3",
"width": 1380
},
"threshold": 0.5,
"warnings": [
"Table regions are boxes only; no rows, cells, or text were reconstructed"
]
}
},
"result_validated": true,
"stage_attempt_id": "4eae96eb-a4d6-4cc2-8634-c7987f3721df",
"status": "succeeded"
}
],
"billing": {
"accepted_customer_ceiling_micros": 70000,
"held_remaining_micros": 64000,
"unit": "micro_usd"
},
"created_at": "2026-10-30T04:55:54.620501Z",
"deadline_at": "2026-10-30T05:55:43.978543Z",
"job_id": "97ecdd70-3786-41bf-84fb-f0e0ba574433",
"job_kind": "pipeline_segmentation",
"max_stage_attempts": 1,
"pages": [
{
"height": 796,
"page_number": 1,
"raster_sha256": "24d80ba381884019312ccfa76b448e2220b1b625a17a51f233468d7ef3b20bc9",
"source_item_id": "507c3d01-2dbd-466e-b039-5dfcaf09c08b",
"source_pdf_page_number": null,
"width": 1380
},
{
"height": 796,
"page_number": 2,
"raster_sha256": "789b0e0e40231d95bf9adfdb491e03d940816fa57d705af94a3806cf5f7557d3",
"source_item_id": "74a95fb6-781a-45e7-a352-2eeb81841ff5",
"source_pdf_page_number": null,
"width": 1380
}
],
"plan_record_id": null,
"schema_version": 1,
"selection_constraints": {
"accepted_reader_provider_ceiling_micros": 64000,
"crop_padding_px": 0,
"deadline_at": "2026-10-30T05:55:43.978543Z",
"max_attempts_per_region": 1,
"max_concurrency": 1,
"max_deadline_ms": 3563330,
"max_input_bytes": 100000000,
"max_output_tokens": 16384,
"max_regions": 16,
"max_total_pixels": 25000000,
"reader_customer_per_attempt_micros": 4000,
"reader_provider_per_attempt_micros": 4000
},
"source_batch_id": "91f3c13d-d4e7-4526-b88c-a7906894c84e",
"source_page_count": 2,
"stage_state": "awaiting_selection",
"state": "awaiting_selection",
"updated_at": "2026-10-30T04:55:54.620501Z"
}6. Select regions to read
Build the selection from the retained stages and accepted source proofs. This builder selects every detected region on every page. Optionally set SKIP_LABEL="footer" to omit footer reads; keep all detected regions in the manifest, and filter only selected_region_ids. Each page is matched to its accepted source by page_number, preserving that page's raster and PDF proof. Review the boxes first for dense ledgers; the detector can return a broad table box rather than individual cells. POST /v1/stratus/jobs/{job_id}/selection with a stable JSON idempotency_key. The selection cannot exceed the accepted job limit.
# Review boxes first. Empty means read every region; use "footer" to skip footers.
SKIP_LABEL=""
SELECTION_REQUEST="$(echo "$STAGES" | jq -ce --arg skip_label "$SKIP_LABEL" \
--arg key "$(python3 -c 'import uuid; print(uuid.uuid4())')" '
. as $s | .accepted_request as $accepted | .selection_constraints as $limits |
[.pages[] | . as $p |
($s.attempts | map(select(.page_number == $p.page_number)) |
max_by(.attempt_number)) as $attempt |
($accepted.sources[] | select(.page_number == $p.page_number)) as $source |
if $attempt.status != "succeeded" or $attempt.financially_settled != true or
$attempt.result_validated != true or $source.source_item_id != $p.source_item_id or
$source.raster_sha256 != $p.raster_sha256 then
error("Page detection or source proof is not ready")
else {page:$p, source:$source, detected:$attempt.result.segmentation_result} end
] | sort_by(.page.page_number) as $pages |
[$pages[] | . as $page | .detected.regions[] |
{id, label, bbox, polygon, cell, reading_order, confidence,
page_number:$page.page.page_number,
kind:(if .cell != null then "table_cell" else "other" end),
kind_source:"caller_assigned",
provenance:{provider:"openocr-pipeline-stage",
engine_id:$accepted.segmentation_engine_id,
model_revision:$accepted.segmentation_revision, operation:"segmentation",
prompt_revision:null, settings_fingerprint:null, requested_context:null,
effective_context:null, output_scope:"page"}}] as $regions |
[$regions[] | select($skip_label == "" or .label != $skip_label) | .id] as $selected |
1 as $max_attempts |
if ($pages | length) != ($accepted.sources | length) or
($selected | length) == 0 or ($selected | length) > $limits.max_regions then
error("Select between 1 and the accepted max_regions; include every source page")
else {idempotency_key:$key, plan:{
schema_version:1, source_batch_id:$s.source_batch_id,
segmentation_manifest:{engine_id:$accepted.segmentation_engine_id,
model_revision:$accepted.segmentation_revision, revision:"pipeline-stage-v1",
evidence_kind:"client_supplied",
pages:[$pages[] | {page_number:.page.page_number,
raster_sha256:.page.raster_sha256, region_ids:[.detected.regions[].id]}],
regions:$regions, provider_cost_micros:null},
pages:[$pages[] | .page as $p | {page_number:$p.page_number,
source_item_id:.source.source_item_id, raster_sha256:.source.raster_sha256,
width:.source.width, height:.source.height, pdf:.source.pdf,
display:{rotation_degrees:0, scale:1, width:$p.width, height:$p.height,
original_to_display:[1,0,0,1,0,0]}}],
selected_region_ids:$selected,
reader:{engine_id:$accepted.reader_engine_id, model_revision:$accepted.reader_revision},
max_attempts_per_region:$max_attempts, max_concurrency:$limits.max_concurrency,
max_input_bytes:$limits.max_input_bytes, max_total_pixels:$limits.max_total_pixels,
max_output_tokens:$limits.max_output_tokens,
max_provider_cost_micros:(($selected | length) * $max_attempts * $limits.reader_provider_per_attempt_micros),
deadline_ms:([30000,($limits.max_deadline_ms - 5000)] | min),
crop_padding_px:$limits.crop_padding_px, requested_context:null,
document_context:($accepted.effective_controls.document_context // null),
transcription:($accepted.effective_controls.transcription // null),
prompt_revision:null, settings_fingerprint:null, retention:"history"}} end')"
SELECT_RESPONSE="$(curl -fsS -X POST "$BASE_URL/v1/stratus/jobs/$JOB_ID/selection" \
-H "Authorization: Bearer $OPENOCR_API_KEY" \
-H 'Content-Type: application/json' -d "$SELECTION_REQUEST")"
echo "$SELECT_RESPONSE" | jq .max_provider_cost_micros is the total provider-cost ceiling for the selected regional plan, excluding the already funded detection stages. The router requires it to equal selected_region_ids.length × max_attempts_per_region × selection_constraints.reader_provider_per_attempt_micros. It is not a per-attempt cap or the customer charge. For the seven selected regions in this example, one attempt each at 4,000 provider micro-USD gives 28,000. Read the per-attempt value from the retained stage response. Reload stages after a long delay so the deadline constraint is current.
Complete request and response example
Complete two-page, seven-region selection example built from the retained stages. The shell example fills the same fields from your own retained stage response.
JSON request body
{
"idempotency_key": "select-first",
"plan": {
"crop_padding_px": 0,
"deadline_ms": 30000,
"document_context": null,
"max_attempts_per_region": 1,
"max_concurrency": 1,
"max_input_bytes": 100000000,
"max_output_tokens": 16384,
"max_provider_cost_micros": 28000,
"max_total_pixels": 25000000,
"pages": [
{
"page_number": 1,
"source_item_id": "507c3d01-2dbd-466e-b039-5dfcaf09c08b",
"raster_sha256": "24d80ba381884019312ccfa76b448e2220b1b625a17a51f233468d7ef3b20bc9",
"width": 1380,
"height": 796,
"pdf": null,
"display": {
"rotation_degrees": 0,
"scale": 1,
"width": 1380,
"height": 796,
"original_to_display": [
1,
0,
0,
1,
0,
0
]
}
},
{
"page_number": 2,
"source_item_id": "74a95fb6-781a-45e7-a352-2eeb81841ff5",
"raster_sha256": "789b0e0e40231d95bf9adfdb491e03d940816fa57d705af94a3806cf5f7557d3",
"width": 1380,
"height": 796,
"pdf": null,
"display": {
"rotation_degrees": 0,
"scale": 1,
"width": 1380,
"height": 796,
"original_to_display": [
1,
0,
0,
1,
0,
0
]
}
}
],
"prompt_revision": null,
"reader": {
"engine_id": "mistral-mistral-ocr-4-1",
"model_revision": "mistral-ocr-4-1"
},
"requested_context": null,
"retention": "history",
"schema_version": 1,
"segmentation_manifest": {
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"revision": "pipeline-stage-v1",
"evidence_kind": "client_supplied",
"pages": [
{
"page_number": 1,
"raster_sha256": "24d80ba381884019312ccfa76b448e2220b1b625a17a51f233468d7ef3b20bc9",
"region_ids": [
"page-1:id-r001",
"page-1:id-r002",
"page-1:id-r003",
"page-1:id-r004",
"page-1:id-r005"
]
},
{
"page_number": 2,
"raster_sha256": "789b0e0e40231d95bf9adfdb491e03d940816fa57d705af94a3806cf5f7557d3",
"region_ids": [
"page-2:id-r001",
"page-2:id-r002"
]
}
],
"regions": [
{
"bbox": [
589,
26,
822,
57
],
"confidence": 0.5932497382164001,
"id": "page-1:id-r001",
"label": "header",
"reading_order": null,
"polygon": null,
"cell": null,
"page_number": 1,
"kind": "other",
"kind_source": "caller_assigned",
"provenance": {
"provider": "openocr-pipeline-stage",
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"operation": "segmentation",
"prompt_revision": null,
"settings_fingerprint": null,
"requested_context": null,
"effective_context": null,
"output_scope": "page"
}
},
{
"bbox": [
120,
72,
1324,
580
],
"confidence": 0.8993438482284546,
"id": "page-1:id-r002",
"label": "table",
"reading_order": null,
"polygon": null,
"cell": null,
"page_number": 1,
"kind": "other",
"kind_source": "caller_assigned",
"provenance": {
"provider": "openocr-pipeline-stage",
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"operation": "segmentation",
"prompt_revision": null,
"settings_fingerprint": null,
"requested_context": null,
"effective_context": null,
"output_scope": "page"
}
},
{
"bbox": [
194,
595,
712,
631
],
"confidence": 0.740493655204773,
"id": "page-1:id-r003",
"label": "vision_footnote",
"reading_order": null,
"polygon": null,
"cell": null,
"page_number": 1,
"kind": "other",
"kind_source": "caller_assigned",
"provenance": {
"provider": "openocr-pipeline-stage",
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"operation": "segmentation",
"prompt_revision": null,
"settings_fingerprint": null,
"requested_context": null,
"effective_context": null,
"output_scope": "page"
}
},
{
"bbox": [
1022,
607,
1258,
644
],
"confidence": 0.5386931300163269,
"id": "page-1:id-r004",
"label": "footer",
"reading_order": null,
"polygon": null,
"cell": null,
"page_number": 1,
"kind": "other",
"kind_source": "caller_assigned",
"provenance": {
"provider": "openocr-pipeline-stage",
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"operation": "segmentation",
"prompt_revision": null,
"settings_fingerprint": null,
"requested_context": null,
"effective_context": null,
"output_scope": "page"
}
},
{
"bbox": [
1320,
25,
1350,
119
],
"confidence": 0.5441786050796509,
"id": "page-1:id-r005",
"label": "aside_text",
"reading_order": null,
"polygon": null,
"cell": null,
"page_number": 1,
"kind": "other",
"kind_source": "caller_assigned",
"provenance": {
"provider": "openocr-pipeline-stage",
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"operation": "segmentation",
"prompt_revision": null,
"settings_fingerprint": null,
"requested_context": null,
"effective_context": null,
"output_scope": "page"
}
},
{
"bbox": [
117,
38,
1289,
104
],
"confidence": 0.8004903793334961,
"id": "page-2:id-r001",
"label": "figure_title",
"reading_order": null,
"polygon": null,
"cell": null,
"page_number": 2,
"kind": "other",
"kind_source": "caller_assigned",
"provenance": {
"provider": "openocr-pipeline-stage",
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"operation": "segmentation",
"prompt_revision": null,
"settings_fingerprint": null,
"requested_context": null,
"effective_context": null,
"output_scope": "page"
}
},
{
"bbox": [
121,
92,
1354,
771
],
"confidence": 0.9398114681243896,
"id": "page-2:id-r002",
"label": "table",
"reading_order": null,
"polygon": null,
"cell": null,
"page_number": 2,
"kind": "other",
"kind_source": "caller_assigned",
"provenance": {
"provider": "openocr-pipeline-stage",
"engine_id": "pp-doclayout-v3",
"model_revision": "46bbdf188bb0a772c08aed74882ce7e51a8f1ea6",
"operation": "segmentation",
"prompt_revision": null,
"settings_fingerprint": null,
"requested_context": null,
"effective_context": null,
"output_scope": "page"
}
}
],
"provider_cost_micros": null
},
"selected_region_ids": [
"page-1:id-r001",
"page-1:id-r002",
"page-1:id-r003",
"page-1:id-r004",
"page-1:id-r005",
"page-2:id-r001",
"page-2:id-r002"
],
"settings_fingerprint": null,
"source_batch_id": "91f3c13d-d4e7-4526-b88c-a7906894c84e",
"transcription": null
}
}JSON response body
{
"job_id": "97ecdd70-3786-41bf-84fb-f0e0ba574433",
"job_kind": "regional",
"plan_record_id": "c27b973d-1e1f-468e-ba69-8d2b1c11de42",
"replayed": false,
"schema_version": 1
}7. Retrieve the job and results
GET /v1/stratus/jobs/{job_id} until result.state reaches a terminal state. Inspect result.pages, result.attempts, stage_usage, warnings, and pipeline_billing. Read result.views.text for the assembled document text and result.views.markdown for the assembled Markdown, in document reading order. The router assembles the latest successful read per selected region in page order, using detector reading order and a geometric fallback when ranks are missing. result.reading_order lists the included region IDs; views are null until there is nonempty successful text. Per-region text remains available at result.attempts[].text for inspection and retries. Check the state and warnings; a partial result can omit regions and is not a complete document.
Only pages contributing successful text appear in the views. In result.views.text, pages are separated by a form feed (\f) surrounded by blank lines: \n\n\f\n\n. In result.views.markdown, each included page starts with <!-- page N --> and a blank line, where N is its page number. Reader-origin HTML comment openers (<!--) are escaped to <!-- so they cannot forge page markers. Form feeds inside reader text become spaces in both views; the original reader output remains in result.attempts[].text.
for attempt in $(seq 1 60); do
RESULT_RESPONSE="$(curl -fsS "$BASE_URL/v1/stratus/jobs/$JOB_ID" \
-H "Authorization: Bearer $OPENOCR_API_KEY")"
STATE="$(echo "$RESULT_RESPONSE" | jq -r '.result.state')"
case "$STATE" in succeeded|failed|partial|cancelled) break ;; esac
sleep 2
done
# Stop here if the job is still running: its text is not the final result yet.
case "$STATE" in succeeded|failed|partial|cancelled) ;; *)
echo "Job $JOB_ID is still $STATE; poll GET /v1/stratus/jobs/$JOB_ID again before reading the result." >&2; exit 1 ;;
esac
echo "$RESULT_RESPONSE" | jq .
# Assembled document text (use .result.views.markdown for Markdown).
echo "$RESULT_RESPONSE" | jq -r '.result.views.text // ""'Complete request and response example
Complete selected regional result from the router contract fixture.
JSON response body
{
"billing": {
"applied_to_ocr_micros": 50000,
"charge_pending": false,
"held_micros": 0,
"initial_quote_ceiling_micros": 50000,
"known_charged_micros": 50000,
"released_micros": 0,
"total_reserved_micros": 0,
"unit": "micro_usd",
"unresolved_attempt_count": 0
},
"document": {
"account_id": "48ae4420-4103-41b7-a41e-7809285693f4",
"pages": [
{
"display": {
"height": 100,
"original_to_display": [
1,
0,
0,
1,
0,
0
],
"rotation_degrees": 0,
"scale": 1,
"width": 100
},
"height": 100,
"page_number": 1,
"raster_sha256": "59130f43e0b7f6b823e1750bf9707825454be0a828fd6be65e8064d327559784",
"width": 100
}
],
"schema_version": 1,
"source_id": "workbench:b9d2cb67-fd32-4ffa-ac00-2fd4746c403d",
"source_revision": "fe6b0b0373d18c76630a8ab96aaab1d9c2d599a0520f9875b2146af86e5e5d74"
},
"job_id": "946702bb-1104-4aa2-9b75-38a155c84d68",
"pipeline_billing": {
"accepted_pipeline_ceiling_micros": 200000,
"regional_held_micros": 0,
"regional_known_charged_micros": 50000,
"schema_version": 1,
"stage_held_micros": 0,
"stage_known_charged_micros": 40000,
"stage_unsettled_attempt_count": 0,
"unit": "micro_usd",
"whole_job_charge_pending": false,
"whole_job_held_micros": 0,
"whole_job_known_charged_micros": 90000
},
"plan": {
"account_id": "48ae4420-4103-41b7-a41e-7809285693f4",
"crop_padding_px": 0,
"limits": {
"deadline_ms": 60000,
"max_attempts_per_region": 1,
"max_concurrency": 1,
"max_input_bytes": 100000000,
"max_output_tokens": 16384,
"max_pages": 1,
"max_provider_cost_micros": 25000,
"max_regions": 1
},
"plan_id": "stratus-v1-341abfcaabcc377dc95244c6792d6758c6593950546878a5f4d86117b67573ed",
"prompt_revision": "stratus-regional-context-v1",
"reader": {
"engine_id": "mock-reader",
"model_revision": "loopback-v1",
"permitted_fallbacks": []
},
"requested_context": null,
"retention": "history",
"schema_version": 1,
"segmentation_revision": "pipeline-stage-v1",
"selected_region_ids": [
"page-1:id-loopback-whole-source"
],
"settings_fingerprint": "hmac-sha256:v1:1695aaf74dc116fa7be4e48c6025841be1d8ba82fae41567df91f8bb52d53ff6",
"source_id": "workbench:b9d2cb67-fd32-4ffa-ac00-2fd4746c403d",
"source_revision": "fe6b0b0373d18c76630a8ab96aaab1d9c2d599a0520f9875b2146af86e5e5d74"
},
"plan_record_id": "7ce23389-8b61-4f8b-b902-265f3cfcfc2c",
"region_set": {
"account_id": "48ae4420-4103-41b7-a41e-7809285693f4",
"regions": [
{
"bbox": [
0,
0,
100,
100
],
"confidence": null,
"id": "page-1:id-loopback-whole-source",
"kind": "page_block",
"kind_source": "caller_assigned",
"label": "Whole source page (test loopback)",
"page_number": 1,
"provenance": {
"effective_context": null,
"engine_id": "mock-segmenter",
"model_revision": "loopback-v1",
"operation": "segmentation",
"output_scope": "page",
"prompt_revision": null,
"provider": "openocr-pipeline-stage",
"requested_context": null,
"settings_fingerprint": null
},
"reading_order": null,
"segmentation_revision": "pipeline-stage-v1",
"source_id": "workbench:b9d2cb67-fd32-4ffa-ac00-2fd4746c403d",
"source_revision": "fe6b0b0373d18c76630a8ab96aaab1d9c2d599a0520f9875b2146af86e5e5d74"
}
],
"schema_version": 1,
"segmentation_revision": "pipeline-stage-v1",
"source_id": "workbench:b9d2cb67-fd32-4ffa-ac00-2fd4746c403d",
"source_revision": "fe6b0b0373d18c76630a8ab96aaab1d9c2d599a0520f9875b2146af86e5e5d74",
"warnings": [
{
"code": "client_supplied_segmentation",
"message": "Segmentation provenance was supplied with the manifest and is not independently attested by this service.",
"next_action": null
}
]
},
"result": {
"account_id": "48ae4420-4103-41b7-a41e-7809285693f4",
"attempts": [
{
"attempt_number": 1,
"crop": {
"bbox": [
0,
0,
100,
100
],
"original_to_crop": [
1,
0,
0,
1,
0,
0
],
"sha256": "59130f43e0b7f6b823e1750bf9707825454be0a828fd6be65e8064d327559784"
},
"customer_charge_micros": 50000,
"id": "24b20fad-13eb-4917-bef7-e443ce8d0259",
"page_number": 1,
"plan_id": "stratus-v1-341abfcaabcc377dc95244c6792d6758c6593950546878a5f4d86117b67573ed",
"provenance": {
"effective_context": null,
"engine_id": "mock-reader",
"model_revision": "loopback-v1",
"operation": "regional-recognition",
"output_scope": "region",
"prompt_revision": "stratus-regional-context-v1",
"provider": "openai",
"requested_context": null,
"settings_fingerprint": "hmac-sha256:v1:1695aaf74dc116fa7be4e48c6025841be1d8ba82fae41567df91f8bb52d53ff6"
},
"provider_cost_micros": 25000,
"region_id": "page-1:id-loopback-whole-source",
"state": "succeeded",
"text": "Selected regional read",
"warnings": []
}
],
"pages": [
{
"completed_region_ids": [
"page-1:id-loopback-whole-source"
],
"page_number": 1,
"selected_region_ids": [
"page-1:id-loopback-whole-source"
],
"state": "succeeded",
"unprocessed_region_ids": [],
"warnings": []
}
],
"plan_id": "stratus-v1-341abfcaabcc377dc95244c6792d6758c6593950546878a5f4d86117b67573ed",
"reading_order": [
"page-1:id-loopback-whole-source"
],
"schema_version": 1,
"source_id": "workbench:b9d2cb67-fd32-4ffa-ac00-2fd4746c403d",
"source_revision": "fe6b0b0373d18c76630a8ab96aaab1d9c2d599a0520f9875b2146af86e5e5d74",
"stage_usage": [
{
"customer_charge_micros": 40000,
"elapsed_ms": 8,
"provider_cost_micros": 20000,
"stage": "segment"
},
{
"customer_charge_micros": 50000,
"elapsed_ms": 103,
"provider_cost_micros": 25000,
"stage": "recognize"
}
],
"state": "succeeded",
"views": {
"markdown": "<!-- page 1 -->\n\nSelected regional read",
"text": "Selected regional read"
},
"warnings": [],
"accepted_retry_authorizations": []
},
"schema_version": 1,
"source_pages": [
{
"display": {
"height": 100,
"original_to_display": [
1,
0,
0,
1,
0,
0
],
"rotation_degrees": 0,
"scale": 1,
"width": 100
},
"height": 100,
"page_number": 1,
"raster_sha256": "59130f43e0b7f6b823e1750bf9707825454be0a828fd6be65e8064d327559784",
"source_item_id": "1e66bf56-8cee-4a42-9e1f-42aa905f06fc",
"width": 100
}
],
"caller_controls": {
"document_context": false,
"transcription": false
}
}8. Retry an eligible region
For a completed region with nonempty text, POST /v1/stratus/jobs/{job_id}/retry-quotes with its region ID and reread_success. Accept that returned quote at /v1/stratus/jobs/{job_id}/retry with a fresh JSON idempotency_key. For a failed region, use retry_failed instead. The accepted whole-job allowance is one reader attempt per selected region; a later retry is separately quoted and subject to saved job constraints.
RETRY_QUOTE_REQUEST="$(jq -n --arg region "$(echo "$SELECTION_REQUEST" | jq -r '.plan.selected_region_ids[0]')" \
'{region_id:$region, intent:"reread_success"}')"
RETRY_QUOTE_RESPONSE="$(curl -fsS -X POST "$BASE_URL/v1/stratus/jobs/$JOB_ID/retry-quotes" \
-H "Authorization: Bearer $OPENOCR_API_KEY" -H 'Content-Type: application/json' \
-d "$RETRY_QUOTE_REQUEST")"
RETRY_REQUEST="$(jq -n --arg id "$(echo "$RETRY_QUOTE_RESPONSE" | jq -r '.retry_quote_id')" \
--arg key "$(python3 -c 'import uuid; print(uuid.uuid4())')" \
'{retry_quote_id:$id, idempotency_key:$key}')"
curl -fsS -X POST "$BASE_URL/v1/stratus/jobs/$JOB_ID/retry" \
-H "Authorization: Bearer $OPENOCR_API_KEY" -H 'Content-Type: application/json' \
-d "$RETRY_REQUEST" | jq .Complete request and response example
Complete route-shaped retry quote example; IDs, times and prices are illustrative.
JSON request body
{
"region_id": "page-1:id-loopback-whole-source",
"intent": "reread_success"
}JSON response body
{
"schema_version": 1,
"retry_quote_id": "88888888-8888-4888-8888-888888888888",
"job_id": "946702bb-1104-4aa2-9b75-38a155c84d68",
"region_id": "page-1:id-loopback-whole-source",
"prior_attempt_id": "24b20fad-13eb-4917-bef7-e443ce8d0259",
"attempt_number": 2,
"intent": "reread_success",
"reader": {
"engine_id": "mistral-mistral-ocr-4-1",
"model_revision": "mistral-ocr-4-1",
"recipient_provider": "mistral",
"max_output_tokens": null
},
"customer_charge_micros": 4000,
"provider_cost_micros": 4000,
"expires_at": "2026-10-29T23:59:00Z",
"attempt_deadline_at": "2026-10-30T00:49:00Z"
}Complete request and response example
Complete route-shaped retry acceptance example; a replay returns a shorter response with replayed: true.
JSON request body
{
"retry_quote_id": "88888888-8888-4888-8888-888888888888",
"idempotency_key": "retry-page-1-first"
}JSON response body
{
"schema_version": 1,
"job_id": "946702bb-1104-4aa2-9b75-38a155c84d68",
"attempt_id": "22222222-2222-4222-8222-222222222222",
"region_id": "page-1:id-loopback-whole-source",
"attempt_number": 2,
"state": "queued",
"reader": {
"engine_id": "mistral-mistral-ocr-4-1",
"model_revision": "mistral-ocr-4-1",
"recipient_provider": "mistral",
"max_output_tokens": null
},
"attempt_deadline_at": "2026-10-30T00:49:00Z"
}9. Cancel or delete
These are separate alternatives. Cancel only while a job is active or partial: queued, running, partial, or unknown_upstream; a pipeline waiting for region selection can also be cancelled. A completed selected job returns 422 job_not_cancellable (409 before selection). Delete can be used after completion to remove the job and its retained objects. In-flight attempts can still complete and charge; read the returned fence fields.
Cancel an active job
curl -fsS -X POST "$BASE_URL/v1/stratus/jobs/$JOB_ID/cancel" -H "Authorization: Bearer $OPENOCR_API_KEY" | jq .Complete request and response example
JSON response body
{
"schema_version": 1,
"job_id": "946702bb-1104-4aa2-9b75-38a155c84d68",
"state": "cancelled",
"in_flight_attempts": 0,
"in_flight_may_complete_and_charge": false
}Or delete the job
curl -fsS -X DELETE "$BASE_URL/v1/stratus/jobs/$JOB_ID" -H "Authorization: Bearer $OPENOCR_API_KEY" | jq .Complete request and response example
JSON response body
{
"schema_version": 1,
"job_id": "946702bb-1104-4aa2-9b75-38a155c84d68",
"state": "deleted",
"in_flight_attempts": 0,
"in_flight_may_complete_and_charge": false
}Errors and limits
| HTTP / code | What to do |
|---|---|
| 404 not_found | The job or source item was not found. Check its ID and that it belongs to your account. |
| 401 authentication_error | Check the Bearer API key. |
| 403 insufficient_scope | Use a write-capable key for upload, quote, accept, selection, retry, cancel or delete. |
| 402 insufficient_balance | Add credit before accepting a quote. |
| 422 pipeline_account_mismatch | Omit account_id on a quote, or use the caller account ID. |
| 422 pipeline_source_invalid / pipeline_source_changed | Recheck source_item_id, dimensions and the hash of the stored raster bytes. |
| 422 pipeline_source_unavailable | The uploaded original is unavailable; keep its item ID and try again later. |
| 422 source_not_pdf / pdf_source_page_mismatch | Use the PDF render route only for a PDF; refresh its page count if it changed. |
| 422 pipeline_retention_required | Enable OCR history for the account. Dashboard → Settings → OCR history. |
| 422 pipeline_quote_invalid / pipeline_quote_changed / pipeline_quote_expired | Get a fresh quote for the same current source and controls. |
| 422 pipeline_idempotency_conflict, or pipeline_quote_invalid for an accepted quote resent with changed fields | The same acceptance key or quote was reused for a different request. Inspect the existing job, or quote again with a new key. |
| 422 pipeline_job_exists | Open the job_id named by the error. |
| 422 stratus_spend_cap_exceeded | Accepting this quote would take the account's total Stratus charges and open holds over its lifetime cap. Nothing was held or charged. |
| 409 pipeline_selection_changed | Reload stages and rebuild selection from the retained result. |
| 422 pipeline_plan_invalid / pipeline_stage_evidence_mismatch | Check selected IDs, boxes, source proofs and accepted limits. |
| 422 region_retry_unavailable / region_retry_changed | Reload the latest region attempt before requesting a retry quote. |
| 409/422 job_not_cancellable | Cancel only while the job is active or partial. Delete a completed job instead. |
| 422 retry_quote_expired / retry_quote_changed | Read the retained job and request a new retry quote. |
| 410 stratus_deleted | The retained job has been deleted. |
| 503 pipeline_starting | The detector is waking. Retry after about 30 seconds; no funds were held. |
| 503 stratus_daily_capacity_reached | Stratus has reached today's capacity. Try again after 00:00 UTC. Nothing was held or charged. |
| 503 pipeline_unavailable / pipeline_selection_unavailable | Check capabilities or retry selection later. |
| 503 pipeline_stages_unavailable / pipeline_identity_unavailable / pipeline_admission_unavailable | Keep the job or source and retry later. |
| 413 pipeline_stage_result_too_large | The retained stage response exceeds the inspection limit. |
The qualified offer currently permits at most 4 source pages, PNG/JPEG detector rasters, 16 selected regions across the job, 1 detection attempt per page, and 1 reader attempt per selected region in the accepted job. Each raster is at most 10 MiB and all pages together at most 25 million pixels. A stored PDF needs the separate render response as its raster proof. A PNG/JPEG upload does not need rendering. Read the general API reference for authentication and shared error conventions.