OCR API

turn images and PDFs into Markdown, plain text, and page-level layout JSON from your own product workflow.

Endpoint: POST /api/v1/ocr

Developer API

Recognize documents with one endpoint

Authenticate with a server-side Developer API Key that has the OCR scope, submit exactly one file, public image URL, or Base64 payload, and receive normalized OCR output. Successful calls consume Processing Credits after recognition and every valid-key call is logged for usage reporting.

HTTP endpoint
POST https://your-domain.com/api/v1/ocr
Authorization: Bearer YOUR_API_KEY
OpenAPI: GET /api/v1/openapi

curl file upload

curl -X POST https://your-domain.com/api/v1/ocr \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Idempotency-Key: invoice-001" \
  -F "[email protected]" \
  -F "mode=formatted"

JavaScript image URL

// Run this from your backend, not browser JavaScript.
const res = await fetch('https://your-domain.com/api/v1/ocr', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.DEVELOPER_API_KEY}`,
    'Idempotency-Key': 'scan-001',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    image_url: 'https://example.com/scan.png',
    mode: 'simple'
  })
});
const data = await res.json();

Python Base64

import base64
import requests

with open('receipt.jpg', 'rb') as f:
    encoded = base64.b64encode(f.read()).decode('utf-8')

res = requests.post(
    'https://your-domain.com/api/v1/ocr',
    headers={'Authorization': 'Bearer YOUR_API_KEY'},
    json={
        'base64': encoded,
        'mime_type': 'image/jpeg',
        'file_name': 'receipt.jpg',
        'mode': 'formatted'
    },
    timeout=120,
)
print(res.json())

Request fields

file
Multipart image or PDF file. Supported formats match the web OCR workspace.
image_url
Public HTTP or HTTPS URL for a remote image or PDF. Private, localhost, link-local, and metadata URLs are rejected before OCR.
base64
Base64 file payload. Send mime_type and file_name when the value is not a data URL.
mode
simple for plain text OCR or formatted for Markdown, tables, formulas, and layout blocks.
Idempotency-Key
Optional header for safe retry. The same key and same input can replay a successful result for 24 hours without another charge.

Response contract

200 success

Returns success, request_id, elapsed_ms, markdown, text, pages, and usage.

401 unauthorized

The API key is missing, invalid, or disabled.

402 credits_insufficient

The key owner does not have enough Processing Credits for the estimated page count and OCR mode.

409 idempotency_conflict

The Idempotency-Key was already used with different OCR input.

422 empty_result

The input was processed, but no readable text was found.

429 limit_exceeded or rate_limited

The key hit the daily OCR API limit, page limit, or minimum request interval.

Built for product integrations

The API uses the same OCR normalization, Processing Credit rules, and limits as the web product.

Developer API Key authentication

Users can create Developer API Keys with the OCR scope. The full secret is shown only once and should stay on your server.

Processing Credit metering

Simple and formatted recognition consume Processing Credits by page after successful OCR.

Usage logs

Valid-key requests are recorded with request_id, status, latency, Processing Credits, source type, IP, and user agent.

Data handling boundary

API logs keep metering metadata for monitoring and abuse detection. OCR output is returned to the caller, and failed recognition is not charged.

OCR API FAQ

Authentication, billing, and response details for developers.







Start integrating OCR

Create a Developer API Key, send a test request, and monitor usage from your API key list.

OCR API Documentation | Image to Text