TeX402 Sandbox Ready
Base Mainnet eip155:8453 x402 v2 Gasless USDC

Hardened LaTeX-to-PDF & <300ms Diagnostics API for AI Agents & Apps

Compile multi-file papers, TikZ schematics, Beamer decks, and XeLaTeX CJK documents inside isolated, networkless TeX Live containers — without shipping a 5 GB texlive-full image, managing API keys, or risking \write18 RCE.

$0.008 PDF Compile
Multi-pass + 150-DPI PNG previews
$0.002 <300ms Lint
ChkTeX + single-pass -draftmode
0 ETH Buyer Gas
Base USDC EIP-3009 authorization
Pre-Settlement Guardrails
400 / 429 / 503 never charge USDC
main.tex + refs.bib engine: pdflatex
 1\documentclass[11pt]{article}
 2\usepackage{amsmath,amssymb,biblatex}
 3\addbibresource{refs.bib}
 4\begin{document}
 5\section{Spectral Convergence}
 6For $\alpha > 0$, the Gaussian integral
 7citing Knuth~\cite{knuth1984} evaluates to:
 8\begin{equation}\label{eq:gauss}
 9  \mathcal{I}(\alpha) = \int_{-\infty}^{\infty} e^{-\alpha x^2}\,dx
10    = \sqrt{\frac{\pi}{\alpha}}
11\end{equation}
12See Figure~\ref{fig:envelope} and Eq.~\eqref{eq:gauss}.
13\printbibliography
14\end{document}
Isolated /work tmpfs · --network=none uid=65534
1 Spectral Convergence

For α > 0, the Gaussian integral citing Knuth [1] evaluates to:

ℐ(α) = ∫−∞∞ e−αx2 dx = √(π / α)
(1)
Figure 1: Sandboxed TikZ/PGF Gaussian kernel envelope (α = 1) rendered at 150 DPI.
References — [1] D. E. Knuth, Literate Programming, Comput. J., 1984.
✓ HTTP 200 · PAYMENT-RESPONSE settled PDF + 150-DPI PNG

§ 1. Integration Quickstart

Start in 30 Seconds — MCP Agent, TypeScript SDK, or HTTP 402

Zero account signup or API keys. Fund any EVM wallet with USDC on Base Mainnet (eip155:8453, 0 ETH gas needed) and connect via MCP or @x402/fetch.

Claude Code One-Liner claude mcp add
claude mcp add tex402 \
  -e TEX402_PRIVATE_KEY=0xYOUR_BASE_USDC_PRIVATE_KEY \
  -e TEX402_BASE_URL=https://tex.x.gl \
  -- npx -y tex402-mcp
MCP JSON Config (tex402-mcp) claude_desktop_config.json / .cursor/mcp.json / Antigravity
{
  "mcpServers": {
    "tex402": {
      "command": "npx",
      "args": [
        "-y",
        "tex402-mcp"
      ],
      "env": {
        "TEX402_PRIVATE_KEY": "0xYOUR_BASE_USDC_PRIVATE_KEY",
        "TEX402_BASE_URL": "https://tex.x.gl"
      }
    }
  }
}
Exposes tex402_status (free), tex402_lint ($0.002), and tex402_compile ($0.008 — writes decoded PDF directly to local disk and attaches multimodal 150-DPI PNG page previews without bloating LLM context).

§ 2. Metered Endpoints & Sandbox Security

Transparent Per-Request USDC Pricing

Settled via gasless EIP-3009 TransferWithAuthorization exact USDC authorizations on Base Mainnet (eip155:8453). Discovery, OpenAPI, and health endpoints are always free.

POST /v1/compile
$0.008 USDC

Full multi-pass LaTeX-to-PDF compilation inside a pre-warmed TeX Live container with optional 150-DPI PNG page previews and line-accurate diagnostics.

  • Engines: pdflatex & xelatex (Unicode + Noto CJK + fontspec)
  • Auto multi-pass biber / bibtex, TOC, Beamer overlays & multi-file files map
  • Returns pdf_base64, page_previews_base64 (150-DPI PNGs), and structured diagnostics
  • Hardened sandbox: --network=none, read-only rootfs, 65534:65534, paranoid Kpathsea, 15s cap
POST /v1/lint
$0.002 USDC

Sub-300ms concurrent chktex static analysis + single-pass -draftmode validation without PDF rendering overhead.

  • Built for rapid AI agent self-correction loops at 25% of full compile cost
  • Catches undefined macros, missing packages, math alignment errors & ChkTeX typography warnings
  • Pinpoints exact subfile + 1-based line number with context_snippet & suggested_fix
  • Identical isolated container boundary as POST /v1/compile
Pre-Settlement Buyer Protection: Payload schema & path validation (400), per-IP rate limiting (429 + Retry-After), and bounded worker queue saturation checks (503 + Retry-After) execute ahead of x402 payment verification — malformed or throttled requests are never settled or charged.
Network & Scheme
Base Mainnet (eip155:8453) · exact EIP-3009
Base URL
https://tex.x.gl
USDC Token Contract (6 Decimals)
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913