Overview
The Pricing API is the single source of truth for compute-usage cost calculation on the Allternit platform. Cost is always derived server-side from the measured quantity, unit, and resource type reported by the ACU (computer-use) Python gateway. The gateway posts usage events to this surface, and the platform computescomputed_cost_cents from the canonical rate card in cmd/allternit-api/src/pricing.rs.
Never trust a client-supplied cost. Pricing and margin logic lives in exactly one place so it can change without touching every caller.
Base URL
Authentication
Pricing routes are internal-only and gated by service-to-service authentication, not the standard Clerk bearer-token middleware. The caller must supply a shared secret in thex-allternit-internal-token header.
*In local development, a localhost-only bypass is allowed when no internal token is configured. In production, missing or invalid tokens fail closed with
401 Unauthorized.
See Authentication for platform authentication details.
Rate card
Costs are computed in cents per unit. The default rates are:
These defaults are placeholders pending final margin decisions. Override any rate at runtime with an environment variable:
resource_type:unit pair by upper-casing the string and replacing non-alphanumeric characters with underscores. Unknown resource_type:unit pairs price at zero rather than erroring, so unrecognized meters do not block ingestion or silently invent a price.
Endpoints
Ingest a usage event
idempotency_key — retrying a delivery with the same key is a no-op, not a double charge.
Request body
Example request
Example response
300 seconds × 0.02 cents/second = 6 cents.
Response fields
Error codes
Idempotency
The ingestion route is idempotent onidempotency_key. If two requests arrive with the same key, only the first is inserted; the second returns the same computed_cost_cents without creating a duplicate row. Always supply a stable idempotency_key when retrying network failures.