LiyaEngine Docs
API Reference

Traces

GET /v1/traces, /v1/traces/stats, /v1/traces/{id}, /v1/traces/runs/{kind}/{runId} — read execution traces, statistics and run traces with an API key.

Dashboard

Read-only access to execution traces via API key. This is the same data and the same filters as the dashboard's Trace Explorer and GET /dashboard/traces, served by the same handlers, so a filter or field that works in one works in the other.

Secret keys only

A trace holds prompts and responses, so public embed tokens are refused with 403 EMBED_TOKEN_NOT_ALLOWED. A key with the full or read scope reads with full trace content. A runtime key cannot read traces. Comments, bookmarks and replay belong to a signed-in user, and a replay is a metered model call, so they stay on the Dashboard API.

Traces are retained for the period your plan includes, and a workspace set to minimal capture stores no content. Requests are rate-limited per tenant like the rest of the API, and a raised limit applies here too.

List traces

GET https://api.liyaengine.ai/v1/traces?domain=support&flagged=true&limit=25
Authorization: Bearer liya_xxxxxxxxxxxx
ParameterDescription
limit, offsetPage size (1 to 100, default 25) and offset.
domain, intentOnly requests to this domain or intent.
flaggedtrue for calls a guardrail flagged, false for the rest.
issueOnly calls with a guardrail issue of this kind: safety, validation, grounding or other.
from, toA time window, as ISO 8601 timestamps.
userId, sessionIdOnly calls by this end user or in this session.
modelOnly calls served by this model.
minLatencyMsOnly calls at least this slow.
fromCachetrue for calls answered from cache.
capturefull or minimal, by how the call was captured.
qFree-text search.
sort, orderSort by time (default), latency, ttft or cost, and asc or desc (default).
scope=tracesOne row per trace: a request made directly, an agent run or a workflow run. Narrow with kind=request, agent or workflow, and add nested=true to list what each run started.
{
  "success": true,
  "data": { "traces": [ { "kind": "request", "traceId": "msg_xyz", "intent": "custom_support_resolve_ticket", "flagged": false } ] },
  "pagination": { "total": 412, "limit": 25, "offset": 0 },
  "sort": { "key": "time", "dir": "desc" }
}

Get one trace

GET https://api.liyaengine.ai/v1/traces/msg_xyz
Authorization: Bearer liya_xxxxxxxxxxxx

Returns the full trace for the request: model, input and output tokens, cost, latency, the guardrail issues found and whether the call was flagged, every retrieved chunk with its source and similarity score, the retrieval settings applied, and each agent step. The message_id returned by POST /v1/run is the trace id.

{
  "success": true,
  "data": {
    "trace": {
      "traceId": "msg_xyz",
      "sessionId": "ses_abc",
      "intent": "custom_support_resolve_ticket",
      "modelUsed": "claude-sonnet-5",
      "totalTokens": 1240,
      "costUsd": "0.002100",
      "latencyMs": 340,
      "flagged": false,
      "retrievedContext": [
        { "sourceId": "src_01", "sourceType": "policy", "score": 0.94, "snippet": "Refunds are processed within..." }
      ],
      "agenticSteps": []
    }
  }
}

Get an agent or workflow run trace

GET https://api.liyaengine.ai/v1/traces/runs/agent/{runId}
GET https://api.liyaengine.ai/v1/traces/runs/workflow/{runId}

Returns the run's steps as nested observations, with the model calls and tool calls each step made. 404 TRACE_NOT_FOUND if the run isn't in your workspace.

Trace statistics

GET https://api.liyaengine.ai/v1/traces/stats?from=2026-10-01T00:00:00Z&domain=support

Takes the same filters as the list. Returns totals for the window: request, agent and workflow counts, input and output tokens, cost, latency average and p50, p95 and p99, time to first token, quality score, calls with PII detected, cache hits, issues by category, and a breakdown by intent. GET /v1/traces/intent-stats returns request statistics per intent.

SDKs

Both official SDKs wrap these endpoints as client.traces (JavaScript / TypeScript 0.20.0 and Python 0.20.0).

const { traces, pagination } = await client.traces.list({ domain: 'support', flagged: true, sort: 'latency' });
const trace = await client.traces.get(traces[0].traceId);
const stats = await client.traces.stats({ domain: 'support' });
page = client.traces.list(domain="support", flagged=True, sort="latency")
trace = client.traces.get(page.traces[0].trace_id)
stats = client.traces.stats(domain="support")

Errors

CodeHTTPMeaning
EMBED_TOKEN_NOT_ALLOWED403A public embed token was used. Use a secret API key.
TRACE_NOT_FOUND404No such trace or run in your workspace.
RATE_LIMIT_EXCEEDED429Over the tenant's rate limit. See Retry-After.

On this page