Skip to content

Complete setup guide

End-to-end guide: account → SDK → production patterns → dashboard → alerts. Use this as the single walkthrough for new projects.

Overview

StepWhat you doTime
1Create account & project2 min
2Configure environment variables2 min
3Install & wire SDK5–15 min
4Track APIs, LLMs, payments10–30 min
5Verify ingest & dashboard2 min
6Configure alerts & team5 min

Step 1 — Account and project

  1. Sign up: app.amlexia.com/signup
  2. Create an organization (maps to Clerk org)
  3. Create a project (e.g. production-api)
  4. Open Settings → copy SDK key (am_...)
  5. Store the key in your secrets manager — never commit it

Staging vs production

PatternWhen to use
Two projectsSeparate SDK keys; safest for alerts
One project + AMLEXIA_ENVIRONMENTFilter production / staging in dashboard

Details: Create a project


Step 2 — Environment variables

Add to server env (.env locally, secrets in production):

env
# Required
AMLEXIA_SDK_KEY=am_your_key_here

# Recommended
AMLEXIA_INGEST_URL=https://ingest.amlexia.com
AMLEXIA_ENVIRONMENT=production
AMLEXIA_RELEASE=1.2.3
AMLEXIA_SERVICE_NAME=api
VariableRequiredPurpose
AMLEXIA_SDK_KEYYesIngest authentication
AMLEXIA_INGEST_URLNoDefault https://ingest.amlexia.com; use http://localhost:8787 for local workers
AMLEXIA_ENVIRONMENTNoTags events; powers dashboard env filter & compare
AMLEXIA_RELEASENoDeploy version on each event
AMLEXIA_SERVICE_NAMENoService label (Django default: api)

Full reference: Environment variables

Never in the browser

Do not use NEXT_PUBLIC_AMLEXIA_*, client bundles, or mobile apps for the SDK key.


Step 3 — Install your SDK

bash
npm install @amlexiahq/node
bash
pip install amlexia
# Framework extras:
pip install "amlexia[fastapi]"
bash
go get github.com/amlexiahq/amlexia-go
bash
gem install amlexia

Package reference: SDK feature parity


Step 4 — Wire the client

Node.js (any framework)

typescript
import { AmlexiaClient, wrapFetch } from '@amlexiahq/node';

const client = AmlexiaClient.fromEnv();

// Optional: auto-track all outbound fetch (OpenAI, Stripe, etc.)
globalThis.fetch = wrapFetch(client, fetch);

process.on('SIGTERM', async () => {
  await client.shutdown();
  process.exit(0);
});

Python

python
from amlexia import AmlexiaClient
import atexit

client = AmlexiaClient.from_env()
atexit.register(client.shutdown)

Go

go
client, err := amlexia.NewFromEnv()
if err != nil { log.Fatal(err) }
defer client.Shutdown()

Ruby

ruby
client = Amlexia::Client.from_env
at_exit { client.shutdown }

Framework middleware (inbound HTTP)

FrameworkGuide
ExpressExpress
FastifyFastify
HonoHono
Next.js App RouterNext.js
FastAPIFastAPI
FlaskFlask
DjangoDjango
Bun / Deno / WorkersBun, Deno & Edge

Step 5 — Track what matters

5a. Inbound API routes

Preferred: framework middleware (auto path normalization, trace headers).

Manual (cron, workers, scripts):

typescript
await client.track({
  endpoint: 'cron/sync-inventory',
  method: 'JOB',
  statusCode: 200,
  latencyMs: 4521,
  environment: process.env.AMLEXIA_ENVIRONMENT,
});

5b. OpenAI / Anthropic

Use helpers or manual track with tokens — ingest estimates cost when costUsd is omitted.

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

await trackOpenAiCompletion(client, {
  model: response.model,
  statusCode: 200,
  latencyMs: Date.now() - start,
  usage: response.usage, // prompt_tokens, completion_tokens
});

Full guide: LLM tracking

5c. Stripe / payments

typescript
await client.track({
  endpoint: 'POST /v1/payment_intents',
  method: 'POST',
  statusCode: 200,
  latencyMs,
  provider: 'stripe',
  costUsd: amountUsd,
  metadata: { payment_intent_id: pi.id },
});

5d. Inbound webhooks

typescript
await client.track({
  endpoint: 'POST /webhooks/stripe',
  method: 'POST',
  statusCode: 200,
  latencyMs,
  provider: 'stripe',
  isWebhook: true,
});

5e. Distributed tracing

typescript
import { createTraceContext, childSpan, applyTraceToEvent } from '@amlexiahq/node/tracing';

const root = createTraceContext({ environment: 'production' });
const child = childSpan(root);
await client.track(applyTraceToEvent({
  endpoint: 'POST /internal/job',
  method: 'POST',
  statusCode: 200,
  latencyMs: 100,
}, child));

Full guide: Tracing

5f. HTTP outbound wrapper

HTTP wrapperswrapFetch, Python wrap_requests_session, Go/Ruby equivalents.

5g. OpenTelemetry

Existing OTEL pipeline → OpenTelemetry


Step 6 — Client options (all SDKs)

OptionDefaultUse
flushIntervalMs / flush interval5sBackground upload
maxBatchSize50Events per POST
maxRetries5On network/5xx
sampleRate10.5 = send ~50% of events
diagnosticfalseLog flush errors to stderr

Details: Sampling & diagnostics


Step 7 — Verify integration

Health CLI

bash
npx amlexia health          # Node
amlexia health              # Python
go run .../cmd/amlexia health   # Go
amlexia health              # Ruby

Raw curl

bash
curl -s -X POST https://ingest.amlexia.com/v1/events \
  -H "Content-Type: application/json" \
  -d "{\"sdk_key\":\"am_YOUR_KEY\",\"events\":[{\"endpoint\":\"GET /health\",\"method\":\"GET\",\"status_code\":200,\"latency_ms\":1,\"timestamp\":$(date +%s),\"environment\":\"production\"}]}"

Expect accepted / queued response.

Dashboard

  1. app.amlexia.com → your project
  2. Live — events within seconds
  3. Overview — aggregates within ~1 minute
  4. Providers — after outbound LLM/payment traffic
  5. Sidebar usage meter — confirms billing month count

Troubleshooting: Troubleshooting


Step 8 — Use the dashboard

PagePurpose
OverviewTraffic, latency, errors, cost (reported vs estimated)
LiveReal-time SSE stream
TracesDistributed traces
ProvidersPer-vendor health & model table
OperationsSLO, forecast, incidents
InsightsRecommendations + AI summary
AlertsRules & history
SettingsSDK key, retention, team

Full walkthrough: Using the dashboard

Global filters

  • Time range: 1h / 24h / 7d / 30d
  • Environment: filter by AMLEXIA_ENVIRONMENT
  • Compare: side-by-side two environments
  • Saved views: save filter presets

Step 9 — Alerts

  1. AlertsCreate alert
  2. Pick condition (latency, error_rate, cost, anomaly, …)
  3. Channel: email, Slack, or HTTP webhook
  4. Set threshold and severity

Guide: Alerts


Step 10 — Team & plans


Step 11 — Production checklist

  • [ ] AMLEXIA_SDK_KEY only in server secrets
  • [ ] AMLEXIA_ENVIRONMENT set per deploy
  • [ ] shutdown() / flush() on serverless
  • [ ] Middleware on all HTTP servers
  • [ ] LLM calls include model + tokens (or explicit costUsd)
  • [ ] Stripe/webhooks tracked with provider + isWebhook
  • [ ] npx amlexia health passes in CI or post-deploy
  • [ ] Error-rate alert on critical routes
  • [ ] Staging project or staging environment tag

Best practices


Local development

Run the monorepo workers and point ingest locally:

env
AMLEXIA_INGEST_URL=http://localhost:8787

Guide: Local development


AI-assisted setup

Paste a prompt into Cursor/Copilot: AI setup prompts


Next