Traces and sessionsBeta

See an agent run as one trace with a tree of steps. Add headers to the calls you already make, send your own spans with OpenTelemetry or a Langfuse SDK, then read sessions, traces and search with your key, or query them with SQL.

Beta: this feature is supported, but may change.

How a run becomes a trace

An agent run is many requests: model calls, the tool calls between them, and subagents. Observability shows each run as one session and one trace with a tree of steps. Three sources add up and never replace each other:

SourceWhat you do
Headers on your model callsAdd a session id, traceparent or a step path. No SDK needed
Tool calls and subagents we inferNothing. We read them from your stored traffic
Your own spansSend them with OpenTelemetry or a Langfuse SDK

Claude Code and Codex need nothing: their own session headers already link their turns and subagents.

session ticket-4471
├─ llm  gpt-6-luna          1.2 s   $0.0031
├─ tool lookup_order        0.4 s   (inferred)
└─ llm  gpt-6-luna          0.9 s   $0.0018

Headers on the calls you make

Add any of these to model calls that go through the gateway. A header always wins over the same fact in the body.

FactHeadersOr in the body
Session idX-Explabs-Session-Id, Helicone-Session-Id, x-session-id, x-litellm-session-id, baggage: gen_ai.conversation.id=...metadata.session_id
Parent sessionX-Explabs-Parent-Session-Id, x-parent-session-idmetadata.parent_session_id
Session nameX-Explabs-Session-Name, Helicone-Session-Namemetadata.session_name
Place in your tracetraceparent (W3C)metadata.traceparent
Trace nameX-Explabs-Trace-Namemetadata.trace_name
Step nameX-Explabs-Span-Name, X-Explabs-Step-Namemetadata.span_name
Step path, like /plan/research/search-1X-Explabs-Step-Path, X-Explabs-Session-Path, Helicone-Session-Pathmetadata.step_path
End userX-Explabs-User-Id, Helicone-User-Idmetadata.end_user, safety_identifier, user
TagsX-Explabs-Tags: {"env":"prod"}metadata.tags
  • Limits: ids up to 256 characters, names up to 200, a path up to 512 characters and 32 steps, and 16 tags. A body value that does not fit is skipped, and the request is never refused for it. A malformed X-Explabs-Tags header is still a 400.
  • Every request has a session. If you send none, it is filed under the conversation we recognize, or else under its own trace.
  • A request sent without a session reads "No session" in the Requests table, and its drawer opens its trace. The Sessions view never lists a single call sent without one.
  • Traces live on the Sessions page; there is no separate Traces view. A session opens to its traces (runs) in start order, each one a click from its tree. A trace sent without a session id that has more than one step, such as an agent run from a framework, is listed as its own session with a muted "trace" marker, named by its agent: gen_ai.agent.name, else the resource service.name, else its root span. The Sessions table shows an Agent column, and offers an Agent filter, when the data names one. An old trace link opens the session the trace belongs to.
  • Every gateway request is one span. Its span id comes from the request id, so it is the same in the app, in every API answer and in an export to your own Langfuse. A call without traceparent starts its own trace.
curl https://api.experientiallabs.ai/v1/chat/completions \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "X-Explabs-Session-Id: run-42" \
  -H "X-Explabs-Step-Path: /plan/research/search-1" \
  -H 'X-Explabs-Tags: {"env":"prod","feature":"support"}' \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-6-luna","messages":[{"role":"user","content":"hi"}]}'

Tool calls and subagents we infer

When a response asks for tool calls and the next request carries their results, we add one tool span per call with its name, arguments, result and a duration equal to the gap between the two requests. These spans are marked inferred (inf: 1 in an API answer), because the gap also holds any other work your code did. Subagents come from Claude Code's agent id or a nested traceparent. When you send your own tool spans, yours are the truth.

Inference, search and previews read stored request text, so they work only while your organization stores prompts. GET /api/orgs/{org_id}/observability/availability says which of them can show anything for your organization. A reason is prompt_storage_off, capture_not_segments (this deployment does not index request text), tag_worker_off or observability_store_off.

GET/api/orgs/{org_id}/observability/availability
{
  "capture_pipeline": "segments",
  "prompt_storage": true,
  "tag_worker": false,
  "previews": {"available": true, "reason": null},
  "search": {"available": true, "reason": null},
  "tool_spans": {"available": true, "reason": null},
  "tag_scoring": {"available": false, "reason": "tag_worker_off"}
}

Send your own spans

Spans you send land in the same trace as our model spans when they share the trace id. Our spans add exact tokens, cost and fallback details to yours and never replace them.

You already useChange
OpenTelemetry (any OTLP/HTTP exporter)Point the exporter at https://api.experientiallabs.ai and add your key
A Langfuse SDKSet the Langfuse host to https://api.experientiallabs.ai and the secret key to your xpl_ key. The public key can stay
Method and pathTakes
POST /v1/tracesOTLP over HTTP, protobuf or JSON, optionally gzip
POST /api/otlp/v1/tracesThe same, for setups that only route /api paths
POST /api/public/otel/v1/tracesThe same, at Langfuse's OpenTelemetry path (Langfuse Python SDK v3)
POST /api/public/ingestionThe Langfuse batch ingestion API. Answers 207 with successes and errors per event
GET /api/public/projectsYour project, for the Langfuse SDK's auth check. The project id is your organization id
GET /api/public/health{"status": "OK"}, no key needed

Send the key as Authorization: Bearer, as x-api-key, or as Langfuse's Authorization: Basic base64(public:secret) with your xpl_ key as the secret. Spans always go to the key's own organization. A customer-plan key cannot send spans. gRPC is not supported.

POST/v1/traces
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.experientiallabs.ai"
export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <YOUR_API_KEY>"

What we store and read from spans

  • Span names, ids, parents, times, status, model and token counts are always stored.
  • Inputs, outputs, prompts, tool arguments and tool results are stored only while your organization stores prompts and zero data retention is off. Otherwise we remove them as the span arrives, before anything is written. You still see the shape and timing of the trace.
  • A cost you report on your own span is kept as customer.cost_usd. It is never added to session or trace totals, because our span of the same call carries the exact charged cost.
  • Spans follow your retention settings, and turning storage off removes them with every other copy.
  • Langfuse score-create events become scores on the span or trace they name.
FactAttributes (the first one found wins)
Sessionsession.id, langfuse.session.id, gen_ai.conversation.id, explabs.session.id
End useruser.id, langfuse.user.id, enduser.id
Span typelangfuse.observation.type, openinference.span.kind, gen_ai.operation.name, then the span name
Modelgen_ai.response.model, gen_ai.request.model, langfuse.observation.model.name, llm.model_name, ai.model.id, model
Tokensgen_ai.usage.input_tokens and output_tokens, llm.token_count.*, ai.usage.*, langfuse.observation.usage_details
Tagslangfuse.trace.tags, tag.tags, explabs.tags, explabs.tag.<key>
Step pathexplabs.step_path

A span with no session is filed under its trace. If one span of a trace names the session, later spans of that trace join it, even in later batches.

from openinference.instrumentation.langchain import LangChainInstrumentor
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor

provider = TracerProvider()
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
LangChainInstrumentor().instrument(tracer_provider=provider)

Ingest limits

Limits are per organization. The OpenTelemetry and Langfuse SDK defaults stay well inside them.

LimitValueOver it
Request body4 MiB as sent, 16 MiB after gzip413
Spans in one request2,000The rest are rejected through OTLP partial success (a 413 per Langfuse event)
Span start timeThe last 400 days to 5 minutes aheadThat span alone is rejected; the rest is kept
Requests50 a second, bursts of 100429 with Retry-After
Spans2,000 a second, bursts of 10,000429 with Retry-After
Requests in progress at once4429 with Retry-After

429 means your organization sent too much: slow down. 503 ingest_unavailable means we could not store the spans or the server is busy with other organizations: retry after Retry-After. When a server is busy, an organization below its fair share still gets in, so one organization's flood never blocks another's spans.

StatusCodeMeaning
400invalid_payloadNot an OTLP export or a Langfuse batch
401unauthorizedMissing, unknown or revoked key
413payload_too_largeOver the body limit
415unsupported_media_type, unsupported_encodingNot protobuf or JSON, or not identity, gzip or deflate
429rate_limitedOver a limit above
503ingest_unavailableRetry after Retry-After
429 rate_limited        -> you are over your limit; wait Retry-After, send less
503 ingest_unavailable  -> the server is busy or could not store; wait Retry-After, resend

Read sessions and traces

Any key of your organization reads these. They take the filters of the request list, plus session totals such as requests_min, errors_min, duration_min and session_cost_min.

RouteReturns
GET .../sessionsSessions with totals, sorted by activity, cost, duration, requests or errors
GET .../sessions/{session_id}One session's totals and the previous and next session
GET .../sessions/{session_id}/treeThe session's span tree as one JSON object: roots, each node's children nested in start order, long keys, no bodies (up to 25,000 nodes). Read this first
GET .../sessions/{session_id}/skeletonThe same nodes as compact JSON lines (about 200 bytes each), for large sessions
GET .../sessions/{session_id}/requestsThe session's full request rows in start order, paged
GET .../sessions/{session_id}/turnsEach request's new messages and response, with resent history folded to a count
GET .../sessions/{session_id}/searchText matches inside the session
GET .../sessions/{session_id}/exportThe whole session with bodies, as JSON lines
GET .../tracesTraces with totals, sorted by time, cost, duration, spans or errors
GET .../traces/{trace_id}/treeOne trace's span tree as one JSON object, like the session tree. Looks back 30 days; pass start and end for an older trace
GET .../traces/{trace_id}The same trace as compact JSON lines
GET .../traces/{trace_id}/searchText matches inside the trace
GET .../requests/search?q=Requests whose text matches, with highlighted snippets. At most 30 days, 24 hours by default

Lists and searches page with next_cursor: pass it back as cursor with the same filters until it is null. An unknown id answers 404 session_not_found or trace_not_found. A tree node carries id, kind (request a model call through the gateway, llm your own LLM span, tool, agent, span), name, started_at, duration_ms, status, model, path, tokens, cost_nano_usd, credits, inferred and children. A skeleton line carries id, p (parent), k (r model call, t tool call, a agent, l your own LLM span, s your other spans), n (name), t and d (start and duration in ms), st (0 ok, 1 failed, 2 incomplete, 3 cancelled, 4 running), c (cost in nano-USD) and inf: 1 when the step was inferred.

GET/api/orgs/{org_id}/sessionsGET/api/orgs/{org_id}/sessions/{session_id}/treeGET/api/orgs/{org_id}/traces/{trace_id}/treeGET/api/orgs/{org_id}/requests/search
curl "https://api.experientiallabs.ai/api/orgs/ORG_ID/requests/search?q=timeout&window=7d" \
  -H "Authorization: Bearer <YOUR_API_KEY>"

curl https://api.experientiallabs.ai/api/orgs/ORG_ID/sessions/run-42/tree \
  -H "Authorization: Bearer <YOUR_API_KEY>"

How search matches

Search matches whole words in the stored text of each request: its new messages, tool calls and results, errors and the response. Case does not matter, and every script is searched, Chinese and Japanese included.

You sendIt finds
timeout errorParts that contain both words, anywhere
"connection timeout" (in double quotes)The words side by side, in that order
INV-20391, api.v2The pieces of the term side by side, so INV-20391 does not match inv and 20391 far apart
LisbOnly the word Lisb. There is no prefix or partial-word match

Newest matches come first. With list filters (a model, a key, a status) a page can come back shorter than limit while next_cursor is still set: keep paging until next_cursor is null. A search covers at most 30 days.

curl -G "https://api.experientiallabs.ai/api/orgs/ORG_ID/requests/search" \
  --data-urlencode 'q="connection timeout"' --data-urlencode "window=7d" \
  -H "Authorization: Bearer <YOUR_API_KEY>"

Query with SQL

POST .../trace-sql runs one read-only SELECT over your own requests, spans, sessions and scores. The answer is {columns, rows, truncated, elapsed_ms}. GET .../trace-sql/schema lists the tables and columns. Queries are for org admins and organization-wide keys; a member gets 403 admin_only (the schema stays readable).

  • One SELECT only: joins, subqueries, WITH and UNION work. Table functions, system tables, SETTINGS, FORMAT, comments and a second statement are refused with 400 sql_not_allowed, and the error names the construct.
  • Every table is limited to your organization.
  • Every table is bound to a time window: the last 7 days by default, or start and end in the body, at most 90 days apart. limit defaults to 1,000 rows and allows 10,000. Queries have time, byte and memory limits, and about 100 queries a minute, 2 at a time, per organization. truncated is true when the row limit cut the answer.
POST/api/orgs/{org_id}/trace-sqlGET/api/orgs/{org_id}/trace-sql/schema
curl -X POST https://api.experientiallabs.ai/api/orgs/ORG_ID/trace-sql \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"query": "select model, count() as n from requests group by model order by n desc", "limit": 100}'

Command line

exp traces in the exp command line lists, opens and searches traces, sessions and requests. It prints JSON, a trace or session as its span tree first, and pages with cursors. It signs in with exp login and calls exactly the routes on this page. It ships with the next exp release; until then, use the routes and the agent prompts.

exp login
exp traces --help