Search documentation

Search across all sections and endpoints

FormaTeX
Docsv1

API Reference

Complete reference for the FormatEx REST API. Compile LaTeX documents to PDF with a single HTTP call.

Quick Example

bash
curl -X POST https://api.formatex.dev/api/v1/compile \
  -H "X-API-Key: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"latex": "\\documentclass{article}\\begin{document}Hello!\\end{document}"}' \
  --output document.pdf

Authentication

Two auth methods: JWT tokens for account management, API keys for compilation.

MethodHeaderUsed For
JWT TokenAuthorization: Bearer <token>User management, billing, admin
API KeyX-API-Key: <key>Compilation endpoints

Users

Manage your profile and view usage statistics. All endpoints require JWT.

API Keys

Create and manage API keys for compilation. All endpoints require JWT.

Compilation

Compile LaTeX to PDF. All compilation endpoints require an API Key.

Companion File Uploads

All compile endpoints accept a files field for bundling images, bibliography files, custom classes, and other assets alongside the main document.

JSON + Base64 Mode

json
{
  "latex": "\\documentclass{article}\\begin{document}\\includegraphics{logo}\\end{document}",
  "engine": "pdflatex",
  "files": [
    { "path": "logo.png", "data": "<base64-encoded-content>" },
    { "path": "refs.bib", "data": "<base64-encoded-content>" }
  ]
}

Multipart mode also supported: Content-Type: multipart/form-data with each file as a files field and path set via the filename attribute.

PlanMax FilesMax File SizeMax Total
free0 (not supported)
developer25 MB5 MB
pro510 MB10 MB
scale1010 MB10 MB

Webhooks

Register HTTP callbacks to receive real-time notifications on compilation events. Requires JWT.

EventTrigger
compile.successCompilation completed successfully
compile.failedCompilation failed

Event Payload

json
{
  "event": "compile.success",
  "jobId": "uuid",
  "engine": "pdflatex",
  "durationMs": 1240,
  "timestamp": "2026-02-20T14:30:00Z"
}

If a secret is set, the payload is signed with HMAC-SHA256 delivered in the X-Signature header.

Billing

Subscription management via Polar.sh. Requires JWT authentication.

Plans

View available plans and their limits. Public endpoint.

Plan Comparison

FeatureFreeDeveloperProScale
Compilations/mo1002,00015,000100,000
Timeout30s120s300s300s
Max Size1 MB5 MB10 MB10 MB
Compilation Runs1355
API Keys251025
EnginespdflatexAll 4All 4All 4
At LimitHard blockSoft limitSoft limitSoft limit

MCP Server

Compile LaTeX directly from AI agents — Claude Desktop, Cursor, Claude Code, n8n, and more — with zero local TeX Live installation. Uses your FormatEx API key for authentication.

Available Tools

fix_latexPrompt

Analyzes compilation errors, finds root causes, and returns corrected LaTeX source. Pass it your LaTeX source and error log.

“Use the fix_latex prompt to help me fix this error: [paste error log]”

PDF output: Compiled PDFs are returned as base64 text in the tool result. Ask your agent to decode and save it: “Save the PDF to document.pdf”. Claude Code writes the file directly; Claude Desktop provides a one-liner decode script.

Setup

How it works

Download a small binary (~12 MB). Your AI client spawns it as a background process on startup and communicates via stdin/stdout. No server setup, no open ports.

Step 1 — Build from source

bash
# macOS / Linux
go build -o formatex-mcp ./cmd/mcp
sudo mv formatex-mcp /usr/local/bin/

# Windows
go build -o formatex-mcp.exe ./cmd/mcp

Pre-built binaries coming soon at dl.formatex.zedmed.online.

Step 2 — Configure your AI client

Edit %APPDATA%\Claude\claude_desktop_config.json (Windows) or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS). Restart Claude Desktop after saving.

Windows

json
{
  "mcpServers": {
    "formatex": {
      "command": "C:\\path\\to\\formatex-mcp.exe",
      "env": {
        "FORMATEX_API_KEY": "fex_your_api_key_here"
      }
    }
  }
}

macOS / Linux

json
{
  "mcpServers": {
    "formatex": {
      "command": "/usr/local/bin/formatex-mcp",
      "env": {
        "FORMATEX_API_KEY": "fex_your_api_key_here"
      }
    }
  }
}
Step 3 — Test it: Type “List the available LaTeX engines” — the agent calls list_engines automatically. If it responds with engine descriptions, you're set.

Troubleshooting

Errors

All errors return a consistent JSON format with an error message and optional context.

json
{
  "error": "human-readable error message",
  "plan": "free",
  "limit": 100,
  "used": 100
}

Status Codes

CodeMeaning
400Invalid request body
401Missing or invalid authentication
403Plan limit violated or account deactivated
404Resource not found
409Conflict (e.g., email already registered)
422Compilation failed
429Rate limit exceeded
503Billing not configured

Rate Limits

Endpoint GroupLimit
Auth20 req/min
User management60 req/min
Billing20 req/min
Admin60 req/min
Compilation100 req/min

Ready to start compiling?

Get your API key in 30 seconds. 100 free compilations every month.