Skip to content

Python SDK

bash
pip install amlexia

Package: amlexia (v1.0.2+) · Feature parity

Quick start

python
from amlexia import AmlexiaClient

client = AmlexiaClient.from_env()
client.track(
    endpoint="GET /health",
    method="GET",
    status_code=200,
    latency_ms=12,
    environment="production",
)
client.shutdown()

Client options

OptionDefaultDescription
sdk_keyrequiredProject SDK key
ingest_urlhttps://ingest.amlexia.comIngest base URL
flush_interval_seconds5.0Background flush
max_batch_size50Events per request
max_retries5Upload retries
sample_rate1.0Sampling 0–1
diagnosticFalseStderr diagnostics

Methods

  • track(...) — queue event
  • flush() — send now
  • shutdown() — flush and stop timer

Auto cost

Send model_name, provider, and token fields; ingest applies the same estimation as Node. Or pass cost_usd explicitly.

python
from amlexia.cost import estimate_event_cost_usd

HTTP wrapper

python
from amlexia.http_wrap import wrap_requests_session

LLM helpers

python
from amlexia.openai_helper import track_openai_completion
from amlexia.anthropic_helper import track_anthropic_message

CLI

bash
amlexia health

Framework extras

bash
pip install "amlexia[fastapi]"
pip install "amlexia[flask]"
ModuleFramework
amlexia.fastapi_integrationFastAPI
amlexia.flask_integrationFlask
amlexia.django_integrationDjango
amlexia.tracingManual traces

Event fields