A blazingly fast PGO/BOLT-optimised axum API for compiling La/TeX offline with Tectonic, hosted on Hugging Face Spaces.
Important
\input is not supported as it requires access to your file system.
GET /v2/pdf (compile TeX/LaTeX source)
name type data type description source required stringLa/TeX source code
http code content-type reason 200application/pdfcompiled PDF document 400text/plainbad request 500text/plaininternal server error
curl https://winstxnhdw-tectonic-api.hf.space/api/v2/pdf?source=<TEX_SOURCE_CODE>
You can spin the server up locally by first building the Docker image.
docker build -f Dockerfile.build -t tectonic-api .To enable the fast cache implementation, set the USE_FAST_CACHE build argument to a non-empty value:
docker build \
--build-arg USE_FAST_CACHE=1 \
-f Dockerfile.build \
-t tectonic-api .Finally, you can run the Docker container with the following environment variables.
docker run --init --rm \
-e SERVER_PORT=7860 \
-e MAX_CACHE_MEMORY=12884901888 \
-e CACHE_EXPIRY=3600 \
-p 7860:7860 \
tectonic-apiYou can enable OpenTelemetry support by passing the OTEL_EXPORTER_OTLP_ENDPOINT environment variable. This enables exporting traces, HTTP and process metrics, and logs to the specified OTLP/HTTP endpoint.
docker run --init --rm \
-e SERVER_PORT=7860 \
-e OTEL_RESOURCE_ATTRIBUTES=service.namespace=huggingface,deployment.environment=production \
-e OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp-gateway-prod-ap-southeast-1.grafana.net/otlp \
-e "OTEL_EXPORTER_OTLP_HEADERS=Authorization=Basic%20$OTEL_AUTH_TOKEN" \
-e OTEL_METRIC_EXPORT_INTERVAL=10000 \
-p 7860:7860 \
ghcr.io/winstxnhdw/tectonic-api:main