Skip to content

Repository files navigation

tectonic-api

API build.yml warmer.yml

Open in Spaces Open a Pull Request

A blazingly fast PGO/BOLT-optimised axum API for compiling La/TeX offline with Tectonic, hosted on Hugging Face Spaces.

Usage

Important

\input is not supported as it requires access to your file system.

GET /v2/pdf (compile TeX/LaTeX source)

Parameters

CompileSchema

name type data type description
source required string La/TeX source code

Responses

http code content-type reason
200 application/pdf compiled PDF document
400 text/plain bad request
500 text/plain internal server error

Example cURL

curl https://winstxnhdw-tectonic-api.hf.space/api/v2/pdf?source=<TEX_SOURCE_CODE>

Development

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-api

Telemetry

You 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

About

A blazingly fast API for compiling La/TeX offline with Tectonic, hosted on Hugging Face Spaces.

Topics

Resources

Stars

4 stars

Watchers

1 watching

Forks

Packages

Used by

Contributors

Languages