# LatexConvert Image to LaTeX API (`latexconvert/image-to-latex-api`) Actor

Convert formula images, screenshots, and equation URLs into clean LaTeX with the LatexConvert API.
Provided by latexconvert.com

- **URL**: https://apify.com/latexconvert/image-to-latex-api.md
- **Developed by:** [latexconvert](https://apify.com/latexconvert) (community)
- **Categories:** AI, Integrations, Agents
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## LatexConvert Image to LaTeX API

Convert formula image URLs and uploaded image files into LaTeX with LatexConvert. This Actor is a paid proxy for the LatexConvert API and writes one result row per input image to the default Dataset.

### Input

```json
{
  "imageUrls": [
    "https://example.com/formula.png"
  ],
  "uploadedImages": []
}
````

- `imageUrls`: Public HTTP or HTTPS image URLs.
- `uploadedImages`: Image files uploaded in the Apify Console.

Provide at least one image URL or uploaded image. You can use both input methods in the same run.

### API usage

Set these environment variables before running the examples:

```bash
export APIFY_TOKEN="YOUR_APIFY_TOKEN"
export ACTOR_ID="RuUmfScEITpPXeUU0"
```

#### Image URL with curl

```bash
curl -sS -X POST "https://api.apify.com/v2/acts/$ACTOR_ID/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"imageUrls":["https://example.com/formula.png"]}'
```

#### Image URL with Python

Install the dependency:

```bash
python3 -m pip install requests
```

```python
import json
import os

import requests

APIFY_TOKEN = os.environ["APIFY_TOKEN"]
ACTOR_ID = os.environ.get("ACTOR_ID", "RuUmfScEITpPXeUU0")

url = f"https://api.apify.com/v2/acts/{ACTOR_ID}/run-sync-get-dataset-items"
payload = {
    "imageUrls": ["https://example.com/formula.png"],
}

response = requests.post(
    url,
    headers={
        "Authorization": f"Bearer {APIFY_TOKEN}",
        "Content-Type": "application/json",
    },
    json=payload,
    timeout=360,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
```

#### Local file with curl

This example uploads a local image into an Apify key-value store, then passes the uploaded record URL to the Actor. It requires `jq`.

```bash
export IMAGE_FILE="img/taileformula.png"
export RECORD_KEY="image-$(date +%s)-$(basename "$IMAGE_FILE")"
export CONTENT_TYPE="$(file --brief --mime-type "$IMAGE_FILE")"

export STORE_ID="$(curl -sS -X POST "https://api.apify.com/v2/key-value-stores" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  | jq -r '.data.id')"

curl -sS -X PUT "https://api.apify.com/v2/key-value-stores/$STORE_ID/records/$RECORD_KEY" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: $CONTENT_TYPE" \
  --data-binary "@$IMAGE_FILE"

export FILE_URL="https://api.apify.com/v2/key-value-stores/$STORE_ID/records/$RECORD_KEY?token=$APIFY_TOKEN"

curl -sS -X POST "https://api.apify.com/v2/acts/$ACTOR_ID/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"uploadedImages\":[\"$FILE_URL\"]}"
```

#### Local file with Python

```python
import json
import mimetypes
import os
import pathlib
import time

import requests

APIFY_TOKEN = os.environ["APIFY_TOKEN"]
ACTOR_ID = os.environ.get("ACTOR_ID", "RuUmfScEITpPXeUU0")
IMAGE_FILE = pathlib.Path(os.environ.get("IMAGE_FILE", "img/taileformula.png"))
APIFY_API_BASE = "https://api.apify.com/v2"

headers = {
    "Authorization": f"Bearer {APIFY_TOKEN}",
}

store_response = requests.post(
    f"{APIFY_API_BASE}/key-value-stores",
    headers={**headers, "Content-Type": "application/json"},
    timeout=60,
)
store_response.raise_for_status()
store_id = store_response.json()["data"]["id"]

record_key = f"image-{int(time.time())}-{IMAGE_FILE.name}"
content_type = mimetypes.guess_type(IMAGE_FILE.name)[0] or "application/octet-stream"
record_url = f"{APIFY_API_BASE}/key-value-stores/{store_id}/records/{record_key}"

upload_response = requests.put(
    record_url,
    headers={**headers, "Content-Type": content_type},
    data=IMAGE_FILE.read_bytes(),
    timeout=120,
)
upload_response.raise_for_status()

uploaded_image_url = f"{record_url}?token={APIFY_TOKEN}"
run_url = f"{APIFY_API_BASE}/acts/{ACTOR_ID}/run-sync-get-dataset-items"

run_response = requests.post(
    run_url,
    headers={**headers, "Content-Type": "application/json"},
    json={"uploadedImages": [uploaded_image_url]},
    timeout=360,
)
run_response.raise_for_status()
print(json.dumps(run_response.json(), indent=2, ensure_ascii=False))
```

In the Apify Console, use the `Uploaded images` field to upload files directly instead of creating the key-value store yourself.

### Output

Each image produces one Dataset item:

```json
{
  "index": 0,
  "inputType": "imageUrl",
  "imageUrl": "https://example.com/formula.png",
  "uploadedImage": null,
  "success": true,
  "latex": "E = mc^2",
  "errorCode": null,
  "error": null,
  "mimeType": "image/png",
  "processingTimeMs": 1350,
  "requestId": "run-id-0"
}
```

If no formula is found, the Actor returns a structured error row instead of failing the whole run:

```json
{
  "index": 0,
  "inputType": "imageUrl",
  "imageUrl": "https://example.com/photo.jpg",
  "uploadedImage": null,
  "success": false,
  "latex": null,
  "errorCode": "NO_FORMULAS_FOUND",
  "error": "No mathematical formulas found in the image.",
  "mimeType": null,
  "processingTimeMs": 1200,
  "requestId": "run-id-0"
}
```

### Pricing

The Actor charges one `image-conversion-attempt` event for each valid image URL or accepted uploaded-image reference before it is sent to the conversion API. Each event costs `$0.0015`, so a run with `N` chargeable image inputs costs `N * $0.0015`, plus any standard Apify platform usage costs. The charge applies even if no formula is found, because the image still has to be analyzed by the conversion engine.

Invalid image URL input, such as a non-HTTP URL, is rejected before charging. Uploaded images are charged once the file reference is accepted for processing.

Set `ALLOW_UNCHARGED_RUNS=true` only for private testing before Pay per event pricing is enabled. Set `ALLOW_UNCHARGED_RUNS=false` for public monetized runs so each valid image attempt is charged through Apify.

### Limits

- Maximum `10` image URLs per run.
- Maximum `10` uploaded images per run.
- Maximum uploaded image size is `10 MB`.
- Images are processed one at a time to keep conversion reliability stable.
- Supported image formats are JPEG, PNG, GIF, and WebP.
- The conversion API may reject oversized images, private network URLs, unsupported formats, or slow image downloads.

### Accuracy

Results depend on image quality. Clear printed equations usually work best. Low-resolution screenshots, cropped formulas, handwritten math, unusual notation, or heavy visual noise can reduce accuracy.

# Actor input Schema

## `imageUrls` (type: `array`):

Public image URLs to convert into LaTeX.

## `uploadedImages` (type: `array`):

Upload image files to convert into LaTeX.

## Actor input object example

```json
{}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("latexconvert/image-to-latex-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("latexconvert/image-to-latex-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call latexconvert/image-to-latex-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=latexconvert/image-to-latex-api",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "LatexConvert Image to LaTeX API",
        "description": "Convert formula images, screenshots, and equation URLs into clean LaTeX with the LatexConvert API.\nProvided by latexconvert.com",
        "version": "0.1",
        "x-build-id": "gNKV5MWpWplZQIlNQ"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/latexconvert~image-to-latex-api/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-latexconvert-image-to-latex-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/latexconvert~image-to-latex-api/runs": {
            "post": {
                "operationId": "runs-sync-latexconvert-image-to-latex-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/latexconvert~image-to-latex-api/run-sync": {
            "post": {
                "operationId": "run-sync-latexconvert-image-to-latex-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "imageUrls": {
                        "title": "Image URLs",
                        "minItems": 1,
                        "maxItems": 10,
                        "type": "array",
                        "description": "Public image URLs to convert into LaTeX.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "uploadedImages": {
                        "title": "Uploaded images",
                        "maxItems": 10,
                        "type": "array",
                        "description": "Upload image files to convert into LaTeX.",
                        "items": {
                            "type": "string"
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
