Skip to content

Cost tracking & usage limits

How Amlexia handles dollar metrics and monthly event quotas.

Reported vs estimated cost

cost_source (ingest)Meaning
reportedYou sent cost_usd / costUsd > 0
estimatedPlatform computed from model + tokens + pricing table
(null)No cost data

Ingest runs enrichment on every event:

  1. If cost_usd > 0reported
  2. Else if model_name + provider + tokens → estimated via estimateEventCostUsd
  3. Else cost charts may show $0; latency/errors still work

Node.js — send explicit cost

typescript
await client.track({
  endpoint: 'POST /v1/chat/completions',
  method: 'POST',
  statusCode: 200,
  latencyMs: 400,
  provider: 'openai',
  modelName: 'gpt-4o-mini',
  tokensInput: 500,
  tokensOutput: 120,
  costUsd: 0.00042, // optional — omit to estimate
});

Node.js — estimate locally

typescript
import { estimateEventCostUsd } from '@amlexiahq/node';

const usd = estimateEventCostUsd({
  modelName: 'gpt-4o-mini',
  provider: 'openai',
  tokensInput: 500,
  tokensOutput: 120,
});

Python

python
from amlexia.cost import estimate_cost_usd

client.track(..., cost_usd=0.01)  # reported
# Or omit cost_usd and send model_name + tokens for estimate

Stripe / payments

Amlexia does not read your Stripe dashboard. Send:

typescript
costUsd: chargeAmountUsd,
provider: 'stripe',

Dashboard

  • Overview → Cost tab: breakdown by endpoint/provider
  • Overview stat cards: reported vs estimated totals
  • Providers: 24h cost per vendor
  • Operations: 30-day LLM spend forecast

Monthly usage limits

PlanEvents / month
Startup10,000
Pro2,000,000
EnterpriseCustom

When exceeded, ingest returns 402. SDKs should not infinite-retry 402.

Check usage: dashboard sidebar meter or GET /api/usage?projectId=.

Reduce volume

  • sampleRate: 0.1 → ~10% of events
  • Separate staging project
  • Avoid tracking health-check spam in middleware (filter in custom middleware if needed)