Extract text with OCR
Standard, Enhanced, and Handwriting OCR turn a scanned PDF or image into HTML, one page at a time.
Authenticate with your personal API key using Authorization: Bearer YOUR_API_KEY.
Price and limits
Choose a mode for each upload; omitting it defaults to standard.
Prices match purchased Document AI credits at $2.50 per 100 credits. API requests draw from your API dollar balance. Your website plan’s included and purchased Document AI credits are separate.
The API reserves the estimated charge before starting. For example, a 10-page Standard PDF reserves 0.20 and the unused $0.05 reservation is released. A failure with no extracted pages releases the whole reservation.
Upload a file of up to 20 MB before base64 encoding. PDFs are counted server-side; each image counts as one page. Supported types are PDF, PNG, JPEG, WebP, BMP, GIF, and TIFF. Multi-frame images are treated as a single image; convert them to PDF to process every page. Password-protected PDFs are unsupported. Enhanced adds independent transcription and alignment for printed pages. Handwriting transcribes handwritten pages and does not include image-to-text highlighting.
Submit and poll
The following Python example uses the HTTP API and works without an SDK update.
Set SOFERAI_API_KEY in your environment, then run it with a local PDF or image.
POST /v1/ocr/ returns document_id, initial status, num_pages, and
estimated_api_cost_cents. A value of 2.5 means $0.025.
GET /v1/ocr/{document_id} returns PENDING, PROCESSING, COMPLETED, or
FAILED, along with page counts, a failure reason when available, and the HTML
already extracted. A failed job can still have successfully extracted pages.
Save your document ID and resume polling it after a connection failure. Submitting
the file again creates another document and another charge.
The same document ID works with the Documents API to retrieve, rename, move, or
translate your document. Supply an owned folder_id at creation to place it in a
folder. Translation is a separate billable operation.
