# Kalmia > Kalmia is an observability platform for LLM agents: capture agent runs as traces, watch them live, and get root-cause verdicts, evals, behavior detection, and analytics over them. Ingestion and read endpoints authenticate with a workspace API key (`Authorization: Bearer kal_live_...`). The SDKs are `pip install kalmia` (Python) and `npm install kalmia-sdk` (TypeScript). Machine-readable contract (OpenAPI 3.1, public, no auth): https://www.kalmia.dev/api/v1/openapi.json. Read endpoints reject unknown query parameter names with 400 rather than silently ignoring them. ## Setting up Kalmia in a codebase To instrument a repository, read https://www.kalmia.dev/setup.md and follow it: it picks the integration path (Python SDK, TypeScript SDK, Vercel AI SDK, OpenTelemetry, or direct ingestion), installs, wraps the LLM client, and ends with a verification step. The same procedure as an installable agent skill: https://www.kalmia.dev/skills/kalmia-setup/SKILL.md. ## API (workspace API key) - POST https://www.kalmia.dev/api/v1/traces/ingest: ingest pre-built traces (single or array, <=100/request) - POST https://www.kalmia.dev/api/otel/v1/traces: OTLP/HTTP ingest (protobuf or JSON) - GET https://www.kalmia.dev/api/v1/traces: list traces; filters provider, status (error|ok|in_progress|completed|stalled), from/to; keyset pagination via limit + cursor -> nextCursor - GET https://www.kalmia.dev/api/v1/traces/summary: one aggregate over a window (from/to required, <=92 days; optional model, variants) -> counts, errored/retried counts, errorRate, costUsdSum + pricedCount, the model/tool cost split with toolCostByService, latency p50/p95, score averages, plus the prior window - GET https://www.kalmia.dev/api/v1/traces/{id}: one full trace - every span with complete input/output, tool args/results, and metrics - POST https://www.kalmia.dev/api/v1/traces/{id}/feedback: attach end-customer feedback { rating: up|down, comment } - GET https://www.kalmia.dev/api/v1/verdicts?traceId=: root-cause verdict; a read never triggers analysis, { verdict: null } means judging is still pending - GET https://www.kalmia.dev/api/traces/analytics: time-bucketed trend series (latency, cost, error rate, tokens); siblings /facets, /summary, /behavior-rate - GET|POST|DELETE https://www.kalmia.dev/api/annotations: read, create, or delete behavior annotations on traces - GET|POST|PUT|DELETE https://www.kalmia.dev/api/annotations/behaviors: manage behavior definitions - POST https://www.kalmia.dev/api/annotations/detect-batch: async batch behavior detection over candidate trace ids -> { runId }; poll /api/annotations/detect-runs/{runId} - POST https://www.kalmia.dev/api/v1/anomaly-scans: trigger an anomaly scan (optional variant scope + from/to window); findings land on GET /api/v1/anomaly-findings - GET https://www.kalmia.dev/api/v1/anomaly-findings?scanId=regression: read regression-investigation findings (starting one, POST /api/v1/regressions, is a signed-in dashboard action and does not accept an API key) - POST https://www.kalmia.dev/api/v1/traces/{id}/analyze: (re-)run the root-cause judge on one trace; GET the same path for the state of that run - POST https://www.kalmia.dev/api/v1/traces/{id}/investigate: start a multi-step investigation of one trace - GET https://www.kalmia.dev/api/errors?from=&to=: the Issues tab's grouped issues over a window; /api/errors/{fingerprint} for one group and its occurrences; POST /api/errors/{fingerprint}/fix for a fix recommendation - GET|PATCH https://www.kalmia.dev/api/v1/monitoring: scheduled-monitoring settings (sweeps, email digests, Slack and Teams destinations); POST /api/v1/monitoring/slack-link returns a Slack approval link, POST /api/v1/monitoring/teams stores a Teams Workflows webhook - GET https://www.kalmia.dev/api/v1/monitor-sweeps: recent scheduled sweeps with their digests and audit coverage - POST https://www.kalmia.dev/api/traces/search: LLM-ranked semantic search over supplied traces - POST https://www.kalmia.dev/api/mcp: MCP server - read tools for evals, traces, verdicts, and anomaly findings, compare_metrics (side-by-side metrics by variant or model), and get_monitoring_settings, plus approval-gated actions (analyze_trace, investigate_trace, annotate_trace, run_sweep, configure_monitoring, connect_slack, connect_teams) Full endpoint list: https://www.kalmia.dev/docs/api-reference ## Cost tracking for third-party services Kalmia prices what an agent spends beyond the model with no setup: log the raw API response as the output of a tool span (`traced(..., span_type="tool")` in Python, `span.traced(name, fn, { type: "tool" })` in TypeScript). Recognized automatically: - exact, from the response: Exa, Valyu, Perplexity, OpenRouter, Twilio - estimated, from the published rate: Tavily, Brave Search, Serper, Parallel Search, Google Custom Search, Exa - built-in provider tools counted from the LLM call: Claude web search, OpenAI web search, OpenAI file search For any other paid call, include `cost_usd` (USD, per call) in the logged output: ```python with traced(name="scrape_page", span_type="tool") as span: result = client.scrape(url) span.log(input={"url": url}, output={**result, "cost_usd": 0.002}) ``` ```ts await span.traced('scrape_page', async (toolSpan) => { const result = await client.scrape(url); toolSpan.log({ input: { url }, output: { ...result, cost_usd: 0.002 } }); }, { type: 'tool' }); ``` Per trace: metrics.costUsd = llmCostUsd + toolCostUsd, with toolCostByService keyed by service (or by the tool name for a cost_usd field). Fleet-wide: GET /api/v1/traces/summary returns llmCostUsdSum, toolCostUsdSum, toolCostByService. ## Docs Every page below is plain markdown. All of them in one file: https://www.kalmia.dev/llms-full.txt - [Introduction](https://www.kalmia.dev/docs.md): What Kalmia is and how the pieces fit together - [Quickstart](https://www.kalmia.dev/docs/quickstart.md): Install the SDK, wrap your client, and see your first trace in minutes - [Capture Traces](https://www.kalmia.dev/docs/capture.md): Getting traces in: SDK wrappers (OpenAI, Anthropic, Vercel AI SDK), agent tracing, live streaming, customer feedback, OpenTelemetry, direct ingestion - [Watch](https://www.kalmia.dev/docs/watch.md): Watching live runs: status lifecycle, run flags, narration, repo-grounded fix recommendations - [Concepts](https://www.kalmia.dev/docs/concepts.md): The data model: traces and spans, computed metrics, workspaces and roles, API key scopes, GitHub repo connect, rate limits - [Verdicts & issues](https://www.kalmia.dev/docs/investigate.md): Root-cause verdicts, the trace investigator, Ask Kalmia (the in-app guide), trace list search and filters, and semantic search - [Issues tab](https://www.kalmia.dev/docs/issues.md): The Issues tab: every issue across your runs grouped by failure, with severity, source, verification, and fix recommendations - [Evaluate](https://www.kalmia.dev/docs/evaluate.md): The judge (engine and model), behaviors and rules, domain context, and running evals - [Detect](https://www.kalmia.dev/docs/detect.md): Behavior detection, the anomaly scan, the prompt audit, regression investigation, and scheduled monitoring with email, Slack, and Teams digests - [Analytics](https://www.kalmia.dev/docs/analytics.md): Per-run metrics, comparison by variant or model, cost estimation, and trends over time - [Reference](https://www.kalmia.dev/docs/api-reference.md): Every HTTP endpoint with auth modes, rate limits, and the MCP server - [Help](https://www.kalmia.dev/docs/support.md): How to contact Kalmia for help, security reports, and data requests ## Guides - [Using the Kalmia SDK](https://www.kalmia.dev/docs/guides/kalmia-sdk.md): Using the Kalmia SDK end to end - [Running evals](https://www.kalmia.dev/docs/guides/evals.md): Running evals against your own test set and closing the loop over MCP - [Comparing variants](https://www.kalmia.dev/docs/guides/comparing-variants.md): Comparing agent variants or models side by side, in the dashboard or over MCP - [Variant metrics](https://www.kalmia.dev/docs/guides/variant-metrics.md): Reading the per-variant metric table - [Behavior detection](https://www.kalmia.dev/docs/guides/behavior-detection.md): Defining behaviors and running detection ## SDKs - [Python SDK (PyPI)](https://pypi.org/project/kalmia/): zero-dependency tracing for OpenAI and Anthropic - [TypeScript SDK (npm)](https://www.npmjs.com/package/kalmia-sdk): tracing with AsyncLocalStorage context and Vercel AI SDK middleware