API Documentation
Image to Markdown API
Convert image files to Markdown format with text extraction and layout preservation
Overview
The Image to Markdown API converts image files to Markdown format with text extraction and layout preservation. It uses a unified JSON request format, accepting either URL references or base64-encoded image data.
Authentication
The API supports two authentication methods:
- API Key: Pass your API key as a query parameter
?key=YOUR_API_KEY
Convert Image to Markdown
Convert an image file to Markdown format with text extraction and layout preservation.
Request
POST /api/image-to-markdownParameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| document | object | Yes | Document object |
| document.type | string | Yes | Fixed value "image_url" |
| document.image_url | string | Yes | Image URL or base64 data |
| filename | string | No | Filename (recommended for base64 data) |
| key | string | No | API key (query parameter, optional for logged-in users) |
Examples:
Using Image URL:
curl -X POST "https://llmocr.com/api/image-to-markdown?key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {
"type": "image_url",
"image_url": "https://llmocr.com/image.jpg"
}
}'Using Base64 Image Data:
curl -X POST "https://llmocr.com/api/image-to-markdown?key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {
"type": "image_url",
"image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA..."
},
"filename": "my-image.jpg"
}'Response
Parameters:
| Parameter | Type | Description |
|---|---|---|
| id | string | Database record ID |
| filename | string | Filename |
| content | string | Complete Markdown content extracted from image |
| format | string | Output format, fixed as "markdown" |
| timestamp | number | Processing completion timestamp |
| payload | string | API endpoint URL |
Example:
{
"id": "67890",
"filename": "image.jpg",
"content": "# Title from Image\n\nExtracted text content in Markdown format...\n\n- Bullet point 1\n- Bullet point 2\n\n| Column 1 | Column 2 |\n|----------|----------|\n| Data 1 | Data 2 |",
"format": "markdown",
"timestamp": 1640995200000,
"payload": "https://llmocr.com/api/image-to-markdown?key=YOUR_API_KEY"
}