POST v3/latex (deprecated)
POST api.mathpix.com/v3/latex
The v3/latex endpoint is deprecated. Please use v3/text instead.
Legacy endpoint for processing equation images. Returns recognized LaTeX in various formats.
Request parameters
You can send an image URL in a JSON body (src field) or upload a file via multipart form-data (with options_json).
src Image URL
tags Tags are lists of strings that can be used to identify results
async This flag is to be used when sending non-interactive requests
formats String postprocessing formats (see Formatting)
ocr Process only math ["math"] or both math and text ["math", "text"].
format_options Options for specific formats (see Format Options)
skip_recrop Force algorithm to consider whole image
confidence_threshold Set threshold for triggering confidence errors
beam_size Number of results to consider during recognition
n_best Number of highest-confidence results to return. Requires beam_size to be set
region Specify the image area with the pixel coordinates top_left_x, top_left_y, width, and height
callback metadata Key value object
include_detected_alphabets Return detected alphabets
auto_rotate_confidence_threshold Specifies threshold for auto rotating image to correct orientation. Can be disabled with a value of 1 (see Auto rotation section for details).
enable_blue_hsv_filter Enables a special mode of image processing where it OCRs blue hue text exclusively.
Formatting
| Format | Description |
|---|---|
| text | text mode output, with math inside delimiters, eg. test \(x^2\), inline math by default |
| text_display | same as text, except uses block mode math instead of inline mode when in doubt |
| latex_normal | direct LaTeX representation of the input |
| latex_styled | modified output to improve the visual appearance such as adding '\left' and '\right' around parenthesized expressions that contain tall expressions like subscript or superscript |
| latex_simplified | modified output for symbolic processing such as shortening operator names, replacing long division with a fraction, and converting a column of operands into a single formula |
| latex_list | output split into a list of simplified strings to help process multiple equations |
| mathml | the MathML for the recognized math |
| asciimath | the AsciiMath for the recognized math |
| wolfram | a string compatible with the Wolfram Alpha engine |
Format Options
The optional format_options request parameter allows customizing LaTeX result formats. The options value may specify:
transforms array of transformation names
math_delims displaymath_delims Available transforms:
| Transform | Description |
|---|---|
| rm_spaces | omit spaces around LaTeX groups and other places where spaces are superfluous |
| rm_newlines | uses spaces instead of newlines between text lines in paragraphs |
| rm_fonts | omit mathbb, mathbf, mathcal, and mathrm commands |
| rm_style_syms | replace styled commands with unstyled versions, e.g., bigoplus becomes oplus |
| rm_text | omit text to the left or right of math |
| long_frac | convert longdiv to frac |
rm_fonts and rm_style_syms are implicit in latex_normal, latex_simplified, and latex_list. The long_frac transformation is implicit in latex_simplified and latex_list.
Response body
text Recognized text format
text_display Recognized text_display format
latex_normal Recognized latex_normal format
latex_simplified Recognized latex_simplified format
latex_styled Recognized latex_styled format
latex_list Recognized latex_list format
mathml Recognized MathML format
asciimath Recognized AsciiMath format
wolfram Recognized Wolfram format
position Position object, pixel coordinates
detection_list Detects image properties (see Image Properties)
error US locale error message
error_info Error info object
latex_confidence Estimated probability 100% correct
latex_confidence_rate Estimated confidence of output quality
candidates n_best results
detected_alphabets DetectedAlphabet object
auto_rotate_confidence Estimated probability that image needs to be rotated, see Auto rotation
auto_rotate_degrees Estimated angle of rotation in degrees to put image in correct orientation, see Auto rotation
Image Properties
| Detection | Definition |
|---|---|
| contains_diagram | Contains a diagram. |
| is_printed | The image is taken of printed math, not handwritten math. |
| is_not_math | No valid equation was detected. |