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:

ParameterTypeRequiredDescription
documentobjectYesDocument object
document.typestringYesFixed value "image_url"
document.image_urlstringYesImage URL or base64 data
filenamestringNoFilename (recommended when using base64 data)
keystringNoAPI 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:

ParameterTypeDescription
idstringDatabase record ID
filenamestringFilename
contentstringRecognized formula in LaTeX format
formatstringOutput format, fixed as "latex"
timestampnumberProcessing completion timestamp
payloadstringAPI 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"
}
Formula Recognition API - LLMOCR Developer Guide