OCR Api for Bastion
- Python 3.12+
- FastAPI
- RapidOCR + ONNX Runtime (default)
- OpenCV
- uv
uv sync
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000GET /healthPOST /api/v1/ocr/challenge(multipart/form-datawithfile, optionaldebug=true)POST /api/v1/ocr/challenge/by-object(application/jsonwithobject_key, optionalbucket,version_id,debug)
Configure these environment variables to enable by-object endpoint:
OCRKIT_R2_ENDPOINT_URLOCRKIT_R2_ACCESS_KEY_IDOCRKIT_R2_SECRET_ACCESS_KEYOCRKIT_R2_REGION_NAME(default:auto)OCRKIT_R2_DEFAULT_BUCKETOCRKIT_R2_ALLOWED_BUCKETS(comma-separated whitelist)OCRKIT_R2_READ_TIMEOUT_SECONDS(default:10)
Default engine is rapidocr.
Switch to PaddleOCR (optional dependency):
uv sync --extra paddle
OCRKIT_OCR_ENGINE=paddleocr uv run uvicorn app.main:app --host 0.0.0.0 --port 8000docker compose up --build -d
docker compose psuv run pytest tests/test_samoa_integration.py