API Documentation
Formula Recognition API
Recognize mathematical formulas from images and return results in LaTeX format
Overview
The Formula Recognition API parses mathematical formulas from images and returns the recognition results in LaTeX format. The API supports both handwritten and printed formulas. It uses a unified JSON request format and accepts either URL references or base64-encoded image data.
Authentication
The API supports the following authentication methods:
- API Key: Pass your API key via query parameter
?key=YOUR_API_KEY
Recognize Formula
Recognize mathematical formulas from image files and return LaTeX formatted text.
Request
POST /api/formula-recognition
Parameters:
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 when using base64 data) |
key | string | No | API key (query parameter, optional for logged-in users) |
Example:
Using image URL:
curl -X POST "https://llmocr.com/api/formula-recognition?key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {
"type": "image_url",
"image_url": "https://llmocr.com/formula.jpg"
}
}'
Using Base64 image data:
curl -X POST "https://llmocr.com/api/formula-recognition?key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"document": {
"type": "image_url",
"image_url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEA..."
},
"filename": "formula.jpg"
}'
Response
Parameters:
Parameter | Type | Description |
---|---|---|
id | string | Database record ID |
filename | string | Filename |
content | string | Recognized formula in LaTeX format |
format | string | Output format, fixed as "latex" |
timestamp | number | Processing completion timestamp |
payload | string | API endpoint URL |
Example:
{
"id": "12345",
"filename": "formula.jpg",
"content": "$$\\tilde { Q } ( x ) : = \\frac { 2 } { \\pi } \\Omega$$",
"format": "latex",
"timestamp": 1640995200000,
"payload": "https://llmocr.com/api/formula-recognition?key=YOUR_API_KEY"
}