# Sophnet Image OCR — API Details & Internals

## API Configuration

**Endpoint:** `https://www.sophnet.com/api/open-apis/projects/easyllms/image-ocr`
**Model:** `PaddleOCR-VL-0.9B`
**Request timeout:** 60 seconds

## Supported Input Formats

- **Image:** JPEG/JPG, PNG, GIF, WebP, BMP and other `image/*` MIME types
- **PDF:** Local `.pdf` or PDF URL; multi-page PDFs are rendered at 150 DPI, OCR'd page by page, results merged, temp images deleted automatically

## Dependencies

- `requests>=2.28.0` — HTTP client (always installed)
- `sophnet-tools>=0.0.1` — Sophnet API helpers (always installed)
- `pymupdf>=1.24.0` — PDF page rendering (auto-installed from Aliyun mirror on first PDF use)

## Workflow

### Image

1. Validate input (file path or URL)
2. Convert local files to base64 data URL
3. Call Sophnet OCR API (timeout: 60s)
4. Parse and return Markdown output

### PDF

1. Detect PDF by path/URL extension
2. Create temp directory; download PDF if URL
3. Render each page to PNG (150 DPI) via PyMuPDF
4. OCR each page → append result → delete page temp image
5. Merge with page markers, delete temp directory
6. Output combined Markdown