Export API

This product is not supported for your selected Datadog site. ().
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。
翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください

Overview

The LLM Observability Export API provides endpoints to retrieve span data. These endpoints allow you to programmatically access your LLM Observability data for running external evaluations and exporting spans for offline storage.

By default, we export spans from the past 15 minutes. If you need to search outside of this timeframe, please specify a time range in your request.

Search spans

Use this endpoint to search and filter LLM Observability spans based on specific criteria.

Endpoint
https://api./api/v2/llm-obs/v1/spans/events/search
Method
POST

Request

Headers (required)

  • DD-API-KEY=<YOUR_DATADOG_API_KEY>
  • DD-APPLICATION-KEY=<YOUR_DATADOG_APPLICATION_KEY>
  • Content-Type="application/vnd.api+json"

Body data (required)

FieldTypeDescription
data[required]SearchSpansRequestEntry point into the request body.
{
  "data": {
    "type": "spans",
    "attributes": {
      "filter": {
        "from": "2025-10-27T00:00:00Z",
        "to": "2025-10-29T23:59:59Z",
        "trace_id": "123456789",
        "span_kind": "llm",
        "tags": {
          "test-key": "correct-test-value"
        }
      },
      "page": {
        "limit": 2
      },
      "options": {
        "time_offset": 3600
      },
      "sort": "timestamp"
    }
  }
}

Code example

curl -X POST "https://api.datadoghq.com/api/v2/llm-obs/v1/spans/events/search" \
-H "DD-API-KEY: <YOUR_DATADOG_API_KEY>" \
-H "DD-APPLICATION-KEY: <YOUR_DATADOG_APPLICATION_KEY>" \
-H "Content-Type: application/vnd.api+json" \
-d @- << EOF
{
  "data": {
    "type": "spans",
    "attributes": {
      "filter": {
        "from": "2025-10-27T00:00:00Z",
        "to": "2025-10-29T23:59:59Z",
        "span_id": "14624140233640368324"
      }
    }
  }
}
EOF

List spans

Use this endpoint to retrieve a list of LLM Observability spans.

Endpoint
https://api./api/v2/llm-obs/v1/spans/events
Method
GET

Request

Headers (required)

  • DD-API-KEY=<YOUR_DATADOG_API_KEY>
  • DD-APPLICATION-KEY=<YOUR_DATADOG_APPLICATION_KEY>

Query parameters

ParameterTypeDescription
filter[span_id]stringSearches for a specific span by its span ID.
filter[trace_id]stringSearches for spans by their trace ID.
filter[tag][key]stringSearches for spans by tag key / value pairs.
filter[span_kind]stringThe span kind: “agent”, “workflow”, “llm”, “tool”, “task”, “embedding”, or “retrieval”.
filter[span_name]stringSearches for spans based on their provided name.
filter[ml_app]stringSearches for spans submitted under a particular ML Application.
filter[from]stringMinimum timestamp for requested spans. Supports date-time ISO8601, date math, and regular timestamps (milliseconds). Defaults to the current time minus 15 minutes.
filter[to]stringMaximum timestamp for requested spans. Supports date-time ISO8601, date math, and regular timestamps (milliseconds). Defaults to the current time.
sortstringSort order. Allowed values: timestamp, -timestamp
page[cursor]stringList following results with a cursor provided in the previous query.
page[limit]integerMaximum number of spans in the response. Default: 10. Maximum configurable limit: 5000.

Code example

curl -G "https://api.datadoghq.com/api/v2/llm-obs/v1/spans/events" \
-H "DD-API-KEY: <YOUR_DATADOG_API_KEY>" \
-H "DD-APPLICATION-KEY: <YOUR_DATADOG_APPLICATION_KEY>" \
# searches for spans from the past 15 minutes
--data-urlencode "filter[trace_id]=6903738200000000af2d3775dfc70530"

Response

Both endpoints have the same response format. Results are paginated.

FieldTypeDescription
data[SearchedSpanResource]List of spans matching the search criteria.
metaMetaMetadata about the response.
linksLinksLinks attributes.
{
  "data": [
    {
      "id": "14624140233640368324",
      "type": "span",
      "attributes": {
        "duration": 83000,
        "input": {
          "value": "hi",
          "messages": [
            {
              "content": "hi",
              "role": "user"
            }
          ]
        },
        "metadata": {
          "test-key": "test-value"
        },
        "metrics": {
          "cache_read_input_tokens": 0,
          "cache_write_input_tokens": 0,
          "estimated_cache_read_input_cost": 0,
          "estimated_cache_write_input_cost": 0,
          "estimated_input_cost": 1500,
          "estimated_non_cached_input_cost": 1500,
          "estimated_output_cost": 6000,
          "estimated_total_cost": 7500,
          "input_tokens": 10,
          "non_cached_input_tokens": 10,
          "output_tokens": 10,
          "total_tokens": 20
        },
        "ml_app": "test-ml-app",
        "model_name": "gpt-4o-mini",
        "model_provider": "openai",
        "name": "llm_call_enriched",
        "output": {
          "value": "hello there",
          "messages": [
            {
              "content": "hello there",
              "role": "assistant"
            }
          ]
        },
        "parent_id": "undefined",
        "span_id": "14624140233640368324",
        "span_kind": "llm",
        "start_ns": 1761833858897,
        "status": "ok",
        "tags": [
          "service:test-service",
          "env:prod",
          "ddtrace.version:3.17",
          "test-key:test-value",
          "error:0",
          "source:llm-observability",
          "source:integration",
          "ml_app:test-ml-app",
          "version:",
          "language:python"
        ],
        "tool_definitions": [
          {
            "name": "test-tool",
            "description": "A test tool",
            "schema": {
              "test-key": "test-value"
            }
          }
        ],
        "trace_id": "6903738200000000af2d3775dfc70530"
      }
    }
  ],
  "meta": {
    "elapsed": 336,
    "request_id": "pddv1ChZucHRwTW96NFNfT3Z4bWFLTFBDWkR3Ii0KHYhY65R_1R21AyDpavSaeO2sul_V6omQLAyWutrzEgx-GnVDrZaMu-lW-Yc",
    "status": "done",
    "page": null
  }
}

API standards

SearchSpansRequest

FieldTypeDescription
type [required]stringIdentifier for the request. Set to spans.
attributes [required]SearchSpansPayloadThe body of the request.

SearchSpansPayload

FieldTypeDescription
filterFilterThe search and filter query settings.
optionsOptionsGlobal query options that are used during the query.
pagePageQueryPaging attributes for listing spans.
sortstringSort order. Allowed values: timestamp, -timestamp

Filter

FieldTypeDescription
span_idstringSearches for a specific span by its span ID.
trace_idstringSearches for spans by their trace ID.
tagsDict[key (string), string]Search for spans by tag key / value pairs.
span_kindstringThe span kind: “agent”, “workflow”, “llm”, “tool”, “task”, “embedding”, or “retrieval”.
span_namestringSearches for spans based on their provided name.
ml_appstringSearch for spans submitted under a particular ML Application.
fromstringMinimum timestamp for requested spans. Supports date-time ISO8601, date math, and regular timestamps (milliseconds). Defaults to the current time minus 15 minutes.
tostringMaximum timestamp for requested spans. Supports date-time ISO8601, date math, and regular timestamps (milliseconds). Defaults to the current time.

Options

FieldTypeDescription
time_offsetintegerThe time offset (in seconds) to apply to the query.

PageQuery

FieldTypeDescription
limitintegerMaximum number of spans in the response. Default: 10. Maximum configurable limit: 5000.
cursorstringList following results with a cursor provided in the previous query.

SearchedSpanResource

FieldTypeDescription
typestringType of the span. Allowed values: span. Default: span.
idstringUnique ID of the span.
attributesSearchedSpanObject containing all span attributes and their associated values.

SearchedSpan

FieldTypeDescription
span_idstringAn ID unique to the span.
trace_idstringA unique ID shared by all spans in the same trace.
parent_idstringID of the span’s direct parent.
tags[string]Array of tags associated with your span.
namestringThe name of the span.
statusstringError status (“ok” or “error”).
start_nsintegerThe span’s start time in nanoseconds.
durationfloatThe span’s duration in nanoseconds.
ml_appstringThe name of the span’s LLM Application.
metadataDict[key (string), any]Data about the span that is not input or output related.
span_kindstringThe span kind: “agent”, “workflow”, “llm”, “tool”, “task”, “embedding”, or “retrieval”.
model_namestringThe name of the model used in the request. Only applicable to LLM spans.
model_providerstringThe provider for the model used in the request. Only applicable to LLM spans.
inputSearchedIOThe span’s input information.
outputSearchedIOThe span’s output information.
tool_definitions[ToolDefinition]List of tools available in an LLM request.
metricsDict[key (string), float]Datadog metrics to collect.

SearchedIO

FieldTypeDescription
valuestringInput or output value.
messages[Message]List of messages. This is only relevant for LLM spans.

Message

FieldTypeDescription
contentstringThe body of the message.
rolestringThe role of the entity.

ToolDefinition

FieldTypeDescription
namestringThe name of the tool.
descriptionstringThe description of the tool’s function.
schemaDict[key (string), any]Data about the arguments a tool accepts.

Meta

FieldTypeDescription
elapsedintegerThe time elapsed in milliseconds.
pagePagePaging attributes.
request_idstringThe identifier of the request.
statusstringThe status of the response. Allowed values: done,timeout

Page

FieldTypeDescription
afterstringThe cursor to use to get the next results, if any. To make the next request, use the same parameters with the addition of the page[cursor] field.
FieldTypeDescription
nextstringLink for the next set of results. See Pagination.