List Spans
GEThttps://api.confident-ai.com/v2/spans
Lists the spans in your Confident AI project one page at a time, newest first by default. Filter by type, trace, name, model, prompt or retriever settings, and pass nextCursor back as cursor for the next page. Each span is returned as a summary with a preview of its input and output; retrieve a span by id for its evaluation fields, results and annotations.
curl -X GET "https://api.confident-ai.com/v2/spans" \
-H "CONFIDENT_API_KEY: <PROJECT-API-KEY>"{
"success": true,
"data": {
"spans": [
{
"uuid": "<SPAN-UUID>",
"traceUuid": "<TRACE-UUID>",
"parentUuid": "<PARENT-SPAN-UUID>",
"name": "OpenAI Call",
"type": "SPAN",
"status": "SUCCESS",
"startTime": "2025-01-15T10:30:00.000Z",
"endTime": "2025-01-15T10:30:02.000Z",
"error": null,
"integration": "LangChain",
"provider": "OpenAI",
"model": "gpt-4o",
"endpoint": null,
"cost": 0.00018,
"inputTokenCost": 0.00006,
"outputTokenCost": 0.00012,
"costPerInputToken": 0.0000025,
"costPerOutputToken": 0.00001,
"inputTokenCount": 24,
"outputTokenCount": 12,
"promptAlias": "geography-assistant",
"promptVersion": "00.00.01",
"promptLabel": "production",
"promptCommitHash": "bab04ce",
"embedder": null,
"topK": null,
"chunkSize": null,
"description": null,
"agentHandoffs": null,
"availableTools": null,
"metadata": {
"region": "Europe"
},
"metricCollectionName": "LLM Collection Name",
"inputPreview": "What is the capital of France?",
"outputPreview": "The capital of France is Paris."
}
],
"totalSpans": 1,
"nextCursor": null
},
"deprecated": false
}Headers
CONFIDENT_API_KEYstringRequiredThe API key of your Confident AI project.
Query parameters
pageSizeintegerdefault: 25The number of results per page, at most 100. Defaults to 25.
cursorstringThis is used for pagination, and should be set to the
nextCursorvalue returned in the previous response to get the next page of results.startstringThis filters for results created at or after the specified start datetime, in ISO 8601 format. Defaults to 60 days ago.
endstringThis filters for results created before the specified end datetime, in ISO 8601 format. Defaults to the current time.
ascendingenumdefault: falseThis determines if the field specified in
sortByshould be in ascending order. Defaults tofalse, which returns the newest results first.sortByenumdefault: createdAtThis determines the field to sort by. Defaults to
createdAt.environmentenumThis filters the spans by the environment where their trace was created, and returns spans from all environments if not specified.
typeenumFilter by the specific type of span.
traceUuidstringFilter spans that belong to the trace with this uuid.
namestringFilter spans by their exact name.
hasErrorenumFilter for spans that either failed (true) or succeeded (false).
modelstringFilter LLM spans by the model used.
promptAliasstringThis filters the spans by the prompt alias used.
promptVersionstringThis filters the spans by the prompt version used.
promptLabelstringThis filters the spans by the prompt label used.
promptCommitHashstringThis filters the spans by the exact prompt commit hash used.
embedderstringFilter retriever spans by the embedder model used.
topKinteger | nullFilter retriever spans by the topK value.
chunkSizeinteger | nullFilter retriever spans by the chunk size.
Response
List Spans succeeded.
successbooleanIndicates if the request was successful.
dataobjectShow 3 propertiesHide 3 properties
spanslist of objectsThe list of spans for the current page.
Show 34 propertiesHide 34 properties
uuidstringThis is the unique identifier of the span.
traceUuidstringThis is the uuid of the trace containing the span.
parentUuidstring | nullThis is the uuid of the parent span, or null for a root span.
namestring | nullThis is the name of the span.
typeenumThe kind of work a span records: SPAN for a plain step, LLM for a model call, RETRIEVER for a knowledge-base lookup, TOOL for a tool call, and AGENT for an agent step.
Show 5 enum valuesHide 5 enum values
SPANAGENTTOOLRETRIEVERLLM
statusenumThis represents the error status of a trace or span: SUCCESS when it completed, ERRORED when it failed.
Show 2 enum valuesHide 2 enum values
SUCCESSERRORED
startTimestringThis is the time the span started.
endTimestringThis is the time the span ended.
errorstring | nullThis is the error string that caused the span to fail, or null when no error occurred.
integrationstring | nullThis is the integration associated with the span.
providerstring | nullThis is the LLM provider used in an LLM span.
modelstring | nullThis is the LLM model used in an LLM span.
endpointstring | nullThis is the API endpoint the model was called through in an LLM span.
costnumber | nullThis is the total cost of the span in USD, or null when it is not known.
inputTokenCostnumber | nullThis is the total cost of the input tokens passed to the LLM model in an LLM span.
outputTokenCostnumber | nullThis is the total cost of the output tokens generated by the LLM model in an LLM span.
costPerInputTokennumber | nullThis is the cost per input token of the LLM model for an LLM span.
costPerOutputTokennumber | nullThis is the cost per output token of the LLM model for an LLM span.
inputTokenCountinteger | nullThis is the total number of input tokens passed to the LLM model in an LLM span.
outputTokenCountinteger | nullThis is the total number of output tokens generated by the LLM model in an LLM span.
promptAliasstring | nullThis is the alias of your prompt which is stored on Confident AI.
promptVersionstring | nullThis is the version assigned to your prompt on Confident AI.
promptLabelstring | nullThis is the label assigned to a specific version of prompt on the Confident AI platform.
promptCommitHashstring | nullThis is the hash of the current prompt being logged in the llm span.
embedderstring | nullThis is the embedder model used in a retriever span.
topKinteger | nullThis is the top K chunks retrieved from your knowledge base in a retriever span.
chunkSizeinteger | nullThis is the chunk size of each retrieved context for a retriever span.
descriptionstring | nullThis is a description if the span is a tool span.
agentHandoffsarray | nullThis is the list of agent handoffs associated with an agent span.
availableToolsarray | nullThis is the list of available tools associated with an agent span.
metadataobject | nullThis is any additional metadata associated with the span.
metricCollectionNamestring | nullThis is the name of the metric collection to evaluate the span.
inputPreviewstring | nullThe first characters of the span's input, or null when it has none. Retrieve the span by id for the full value.
outputPreviewstring | nullThe first characters of the span's output, or null when it has none. Retrieve the span by id for the full value.
totalSpansintegerThe total number of spans matching the query across all pages. Present on the first page only; omitted when a
cursoris given.nextCursorstring | nullThe value to pass as
cursorto get the next page, or null when this is the last page.
deprecatedbooleanIndicates if this endpoint is deprecated.