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:
| Source | What you do |
|---|---|
| Headers on your model calls | Add a session id, traceparent or a step path. No SDK needed |
| Tool calls and subagents we infer | Nothing. We read them from your stored traffic |
| Your own spans | Send 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.0018Headers 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.
| Fact | Headers | Or in the body |
|---|---|---|
| Session id | X-Explabs-Session-Id, Helicone-Session-Id, x-session-id, x-litellm-session-id, baggage: gen_ai.conversation.id=... | metadata.session_id |
| Parent session | X-Explabs-Parent-Session-Id, x-parent-session-id | metadata.parent_session_id |
| Session name | X-Explabs-Session-Name, Helicone-Session-Name | metadata.session_name |
| Place in your trace | traceparent (W3C) | metadata.traceparent |
| Trace name | X-Explabs-Trace-Name | metadata.trace_name |
| Step name | X-Explabs-Span-Name, X-Explabs-Step-Name | metadata.span_name |
Step path, like /plan/research/search-1 | X-Explabs-Step-Path, X-Explabs-Session-Path, Helicone-Session-Path | metadata.step_path |
| End user | X-Explabs-User-Id, Helicone-User-Id | metadata.end_user, safety_identifier, user |
| Tags | X-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-Tagsheader is still a400. - 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 resourceservice.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
traceparentstarts 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.
/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 use | Change |
|---|---|
| OpenTelemetry (any OTLP/HTTP exporter) | Point the exporter at https://api.experientiallabs.ai and add your key |
| A Langfuse SDK | Set the Langfuse host to https://api.experientiallabs.ai and the secret key to your xpl_ key. The public key can stay |
| Method and path | Takes |
|---|---|
POST /v1/traces | OTLP over HTTP, protobuf or JSON, optionally gzip |
POST /api/otlp/v1/traces | The same, for setups that only route /api paths |
POST /api/public/otel/v1/traces | The same, at Langfuse's OpenTelemetry path (Langfuse Python SDK v3) |
POST /api/public/ingestion | The Langfuse batch ingestion API. Answers 207 with successes and errors per event |
GET /api/public/projects | Your 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.
/v1/tracesexport 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-createevents become scores on the span or trace they name.
| Fact | Attributes (the first one found wins) |
|---|---|
| Session | session.id, langfuse.session.id, gen_ai.conversation.id, explabs.session.id |
| End user | user.id, langfuse.user.id, enduser.id |
| Span type | langfuse.observation.type, openinference.span.kind, gen_ai.operation.name, then the span name |
| Model | gen_ai.response.model, gen_ai.request.model, langfuse.observation.model.name, llm.model_name, ai.model.id, model |
| Tokens | gen_ai.usage.input_tokens and output_tokens, llm.token_count.*, ai.usage.*, langfuse.observation.usage_details |
| Tags | langfuse.trace.tags, tag.tags, explabs.tags, explabs.tag.<key> |
| Step path | explabs.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.
| Limit | Value | Over it |
|---|---|---|
| Request body | 4 MiB as sent, 16 MiB after gzip | 413 |
| Spans in one request | 2,000 | The rest are rejected through OTLP partial success (a 413 per Langfuse event) |
| Span start time | The last 400 days to 5 minutes ahead | That span alone is rejected; the rest is kept |
| Requests | 50 a second, bursts of 100 | 429 with Retry-After |
| Spans | 2,000 a second, bursts of 10,000 | 429 with Retry-After |
| Requests in progress at once | 4 | 429 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.
| Status | Code | Meaning |
|---|---|---|
400 | invalid_payload | Not an OTLP export or a Langfuse batch |
401 | unauthorized | Missing, unknown or revoked key |
413 | payload_too_large | Over the body limit |
415 | unsupported_media_type, unsupported_encoding | Not protobuf or JSON, or not identity, gzip or deflate |
429 | rate_limited | Over a limit above |
503 | ingest_unavailable | Retry 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, resendRead 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.
| Route | Returns |
|---|---|
GET .../sessions | Sessions 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}/tree | The 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}/skeleton | The same nodes as compact JSON lines (about 200 bytes each), for large sessions |
GET .../sessions/{session_id}/requests | The session's full request rows in start order, paged |
GET .../sessions/{session_id}/turns | Each request's new messages and response, with resent history folded to a count |
GET .../sessions/{session_id}/search | Text matches inside the session |
GET .../sessions/{session_id}/export | The whole session with bodies, as JSON lines |
GET .../traces | Traces with totals, sorted by time, cost, duration, spans or errors |
GET .../traces/{trace_id}/tree | One 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}/search | Text 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.
/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/searchcurl "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 send | It finds |
|---|---|
timeout error | Parts that contain both words, anywhere |
"connection timeout" (in double quotes) | The words side by side, in that order |
INV-20391, api.v2 | The pieces of the term side by side, so INV-20391 does not match inv and 20391 far apart |
Lisb | Only 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
SELECTonly: joins, subqueries,WITHandUNIONwork. Table functions,systemtables,SETTINGS,FORMAT, comments and a second statement are refused with400 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
startandendin the body, at most 90 days apart.limitdefaults 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.truncatedis true when the row limit cut the answer.
/api/orgs/{org_id}/trace-sqlGET/api/orgs/{org_id}/trace-sql/schemacurl -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