1. Bearer API keys, plugin headers and idempotent POST metering
Automation scripts, Make scenarios, n8n workflows, GitHub Actions and marketplace plugins call the exact same stateless engine endpoints (POST /api/v1/engines/<path>). Callers authenticate using either a server-side Bearer key (Authorization: Bearer ak_live_<40 chars>) or an activated plugin triple (X-License-Key, X-License-Sku, X-License-Fingerprint).
Every mutating or metered request accepts Idempotency-Key: <8–128 chars>. If your HTTP client retries after a proxy drop or 5xx timeout with fetchWithBackoff, supplying the same Idempotency-Key returns the cached { ok: true, data, usage } envelope and deducts units once only.
curl -sS -X POST "$BASE_URL/api/v1/engines/alt-text/generate" \
-H "Authorization: Bearer ak_live_example_key_replace_me_0000000000" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: sku-4419-hero-img-v1" \
-d '{
"imageUrl": "https://cdn.example.co.uk/products/sku-4419.jpg",
"context": "Brushed stainless steel 2-gang switched socket with USB-C",
"lang": "en-GB",
"byok": {
"provider": "anthropic",
"apiKey": "sk-ant-..."
}
}'
# Response: { "ok": true, "data": { "alt": "..." }, "usage": { "operation": "alt-text.generate", "units": 1, "balance": 500, "byok": true } }2. Choosing between Bring-Your-Own-Key (BYOK) and prepaid credit packs
Flat-price SaaS subscriptions that promise 'unlimited AI' inevitably impose hidden throttling or sudden plan hikes, while uncapped post-paid token billing exposes engineering teams to runaway loop bills. Our commercial contract enforces a clean split:
- Zero-unit inspection & validation endpoints (
0units):pdf.preview,dpp.qr,dpp.validate,einvoice.validate,vat.validate,omnibus.lowest-priceandllms.validaterun deterministically at0units on an active key (protected by standardX-RateLimit-*headers). - Prepaid credits (
HTTP 402fail-fast floor): Ideal for agencies, storefronts and ops teams that do not want to manage separate OpenAI, Anthropic or Google Cloud billing accounts. If a batch call exceeds remaining credits, the server returns402 { ok: false, error: { code: "insufficient_credits", retryable: false } }before invoking any upstream API. - Bring Your Own Key (
BYOK): Ideal for engineering teams with existing enterprise model agreements (anthropic,openaiorgemini). In plugins,@repo/plugin-kit'screateByokVaultseals your provider key locally, sends it per call over HTTPS, never persists it in server logs, and bills only the base orchestration unit.
3. Offline-capable Ed25519 AKL1 entitlement tokens and AKR1 signed updates
A WordPress, WooCommerce, Shopware or desktop IDE plugin must never break a customer's storefront or build pipeline because a licence server is unreachable for ten minutes. When a plugin calls /api/v1/licenses/activate or /validate, our server issues a compact signed token: AKL1.<base64url(JSON)>.<base64url(Ed25519 signature)>.
Every plugin embeds our 32-byte Ed25519 public key (never the private key) and verifies the signature locally (@noble/ed25519 in TypeScript, sodium_crypto_sign_verify_detached in PHP, java.security Ed25519 on the JVM). Tokens carry a 7-day exp plus an offline grace window: if a background refresh hits a 5xx or network error (retryable: true — not in TERMINAL_ERROR_CODES), verifyLicenseToken continues returning { ok: true, inGrace: true }. Only the five genuine terminal codes (invalid_key, wrong_sku, revoked, expired, trial_ended) deactivate access. Likewise, self-hosted plugin update packages verify AKR1\n<sku>\n<version>\n<sha256> Ed25519 signatures before installing.