Process Equations (deprecated)
Deprecated — use v3/text instead.
Legacy endpoint for processing equation images. Returns recognized LaTeX in multiple output formats.
POST v3/latex
POST api.mathpix.com/v3/latex
Process a single equation image and return recognized LaTeX in multiple output formats. Accepts an image URL or file upload. Use v3/text instead for new integrations.
Example
- cURL
- Python
- JavaScript / TypeScript
- Go
- Java
curl -X POST https://api.mathpix.com/v3/latex \
-H 'app_id: APP_ID' \
-H 'app_key: APP_KEY' \
-H 'Content-Type: application/json' \
--data '{"src": "https://cdn.mathpix.com/examples/equation.jpg", "formats": ["latex_simplified", "text"]}'
import requests
r = requests.post("https://api.mathpix.com/v3/latex",
json={
"src": "https://cdn.mathpix.com/examples/equation.jpg",
"formats": ["latex_simplified", "text"]
},
headers={
"app_id": "APP_ID",
"app_key": "APP_KEY",
"Content-type": "application/json"
}
)
print(r.json())
const response = await fetch("https://api.mathpix.com/v3/latex", {
method: "POST",
headers: {
app_id: "APP_ID",
app_key: "APP_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
src: "https://cdn.mathpix.com/examples/equation.jpg",
formats: ["latex_simplified", "text"],
}),
});
const result = await response.json();
console.log(result);
body := bytes.NewBufferString(`{
"src": "https://cdn.mathpix.com/examples/equation.jpg",
"formats": ["latex_simplified", "text"]
}`)
req, _ := http.NewRequest("POST", "https://api.mathpix.com/v3/latex", body)
req.Header.Set("app_id", "APP_ID")
req.Header.Set("app_key", "APP_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
result, _ := io.ReadAll(resp.Body)
fmt.Println(string(result))
HttpClient client = HttpClient.newHttpClient();
String body = """
{
"src": "https://cdn.mathpix.com/examples/equation.jpg",
"formats": ["latex_simplified", "text"]
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.mathpix.com/v3/latex"))
.header("app_id", "APP_ID")
.header("app_key", "APP_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
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
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 pixel coordinates
callback Webhook for asynchronous result delivery
metadata Key-value object. Supports improve_mathpix for extra privacy controls.
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 only blue hue text.
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
request_id Request ID, for debugging purposes
version Model version used for processing
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)
detection_map Object containing numeric values for each detection type. Keys include contains_chart, contains_diagram, contains_graph, contains_table, is_blank, is_inverted, is_not_math, is_printed.
image_height Height of the processed image in pixels
image_width Width of the processed image in pixels
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 Detected alphabet flags
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
Type definitions
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. |