Skip to content

Authentication

Zouhair Fouiguira edited this page Feb 28, 2026 · 1 revision

Authentication

Getting an API Key

  1. Sign up at app.formatex.io
  2. Go to Dashboard → API Keys → Create Key
  3. Copy the key — it is shown only once

Using the Key

Pass the raw key to the client constructor:

from formatex import FormaTexClient

client = FormaTexClient("fx_your_api_key_here")

Or as a context manager (recommended — ensures connection cleanup):

with FormaTexClient("fx_your_api_key_here") as client:
    result = client.compile(latex)

The SDK sends it as the X-API-Key header on every request.

Keeping Keys Secure

  • Never hardcode keys in source code — use environment variables:
import os
from formatex import FormaTexClient

client = FormaTexClient(os.environ["FORMATEX_API_KEY"])
# .env (never commit this file)
FORMATEX_API_KEY=fx_your_api_key_here

Load .env with python-dotenv:

pip install python-dotenv
from dotenv import load_dotenv
load_dotenv()

client = FormaTexClient(os.environ["FORMATEX_API_KEY"])
  • Add .env to .gitignore
  • In CI/CD, use secrets (GitHub Actions Secrets, etc.)

Key Rotation

  1. Create a new key in the dashboard
  2. Deploy with the new key
  3. Revoke the old key once traffic has fully migrated

Revoking is instant and irreversible.

Multiple Keys

Use separate keys per environment:

Environment Key
Production fx_prod_...
Staging fx_stg_...
CI fx_ci_...

Clone this wiki locally