Skip to main content

POST v3/latex (deprecated)

POST api.mathpix.com/v3/latex

warning

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 string (optional)

Image URL

tags [string] (optional)

Tags are lists of strings that can be used to identify results

async [bool] (optional)

This flag is to be used when sending non-interactive requests

formats string[]

String postprocessing formats (see Formatting)

ocr string[] (optional), default value is ["math"]

Process only math ["math"] or both math and text ["math", "text"].

format_options object (optional)

Options for specific formats (see Format Options)

skip_recrop bool (optional)

Force algorithm to consider whole image

confidence_threshold number in [0,1] (optional)

Set threshold for triggering confidence errors

beam_size number in [1,10] (optional)

Number of results to consider during recognition

n_best integer in [1,beam_size] (optional)

Number of highest-confidence results to return. Requires beam_size to be set

region object (optional)

Specify the image area with the pixel coordinates top_left_x, top_left_y, width, and height

callback object (optional)
metadata object (optional)

Key value object

include_detected_alphabets bool (optional)

Return detected alphabets

auto_rotate_confidence_threshold number in [0,1] (optional), default value is 0.99

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 bool (optional), default value is false

Enables a special mode of image processing where it OCRs blue hue text exclusively.

Formatting

FormatDescription
texttext mode output, with math inside delimiters, eg. test \(x^2\), inline math by default
text_displaysame as text, except uses block mode math instead of inline mode when in doubt
latex_normaldirect LaTeX representation of the input
latex_styledmodified output to improve the visual appearance such as adding '\left' and '\right' around parenthesized expressions that contain tall expressions like subscript or superscript
latex_simplifiedmodified 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_listoutput split into a list of simplified strings to help process multiple equations
mathmlthe MathML for the recognized math
asciimaththe AsciiMath for the recognized math
wolframa 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 string[]

array of transformation names

math_delims [string, string]

[begin, end] delimiters for math mode.

Example

\( and \)

displaymath_delims [string, string]

[begin, end] delimiters for displaymath mode.

Example

\[ and \]

Available transforms:

TransformDescription
rm_spacesomit spaces around LaTeX groups and other places where spaces are superfluous
rm_newlinesuses spaces instead of newlines between text lines in paragraphs
rm_fontsomit mathbb, mathbf, mathcal, and mathrm commands
rm_style_symsreplace styled commands with unstyled versions, e.g., bigoplus becomes oplus
rm_textomit text to the left or right of math
long_fracconvert longdiv to frac
note

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 string (optional)

Recognized text format

text_display string (optional)

Recognized text_display format

latex_normal string (optional)

Recognized latex_normal format

latex_simplified string (optional)

Recognized latex_simplified format

latex_styled string (optional)

Recognized latex_styled format

latex_list string[] (optional)

Recognized latex_list format

mathml string (optional)

Recognized MathML format

asciimath string (optional)

Recognized AsciiMath format

wolfram string (optional)

Recognized Wolfram format

position object (optional)

Position object, pixel coordinates

detection_list string[] (optional)

Detects image properties (see Image Properties)

error string (optional)

US locale error message

error_info object (optional)

Error info object

latex_confidence number in [0,1] (optional)

Estimated probability 100% correct

latex_confidence_rate number in [0,1] (optional)

Estimated confidence of output quality

candidates object[] (optional)

n_best results

detected_alphabets [object] (optional)
auto_rotate_confidence number in [0,1] (optional)

Estimated probability that image needs to be rotated, see Auto rotation

auto_rotate_degrees number in {0, 90, -90, 180} (optional)

Estimated angle of rotation in degrees to put image in correct orientation, see Auto rotation

Image Properties

DetectionDefinition
contains_diagramContains a diagram.
is_printedThe image is taken of printed math, not handwritten math.
is_not_mathNo valid equation was detected.