This product is not supported for your selected Datadog site. ().
Overview
The LLM Observability HTTP API provides an interface for developers to send LLM-related traces and spans to Datadog. If your application is written in Python, Node.js, or Java, you can use the LLM Observability SDKs.
The API accepts spans with timestamps no more than 24 hours old, allowing limited backfill of delayed data.
Spans API
Use this endpoint to send spans to Datadog. For details on the available kinds of spans, see Span Kinds.
{"data":{"type":"span","attributes":{"ml_app":"weather-bot","session_id":"1","tags":["service:weather-bot","env:staging","user_handle:example-user@example.com","user_id:1234"],"spans":[{"parent_id":"undefined","trace_id":"<TEST_TRACE_ID>","span_id":"<AGENT_SPAN_ID>","name":"health_coach_agent","meta":{"kind":"agent","input":{"value":"What is the weather like today and do i wear a jacket?"},"output":{"value":"It's very hot and sunny, there is no need for a jacket"}},"start_ns":1713889389104152000,"duration":10000000000},{"parent_id":"<AGENT_SPAN_ID>","trace_id":"<TEST_TRACE_ID>","span_id":"<WORKFLOW_ID>","name":"qa_workflow","meta":{"kind":"workflow","input":{"value":"What is the weather like today and do i wear a jacket?"},"output":{"value":"It's very hot and sunny, there is no need for a jacket"}},"start_ns":1713889389104152000,"duration":5000000000},{"parent_id":"<WORKFLOW_SPAN_ID>","trace_id":"<TEST_TRACE_ID>","span_id":"<LLM_SPAN_ID>","name":"generate_response","meta":{"kind":"llm","input":{"messages":[{"role":"system","content":"Your role is to ..."},{"role":"user","content":"What is the weather like today and do i wear a jacket?"}]},"output":{"messages":[{"content":"It's very hot and sunny, there is no need for a jacket","role":"assistant"}]}},"start_ns":1713889389104152000,"duration":2000000000}]}}}
Response
If the request is successful, the API responds with a 202 network code and an empty body.
API standards
Error
Field
Type
Description
message
string
The error message.
stack
string
The stack trace.
type
string
The error type.
IO
Field
Type
Description
value
string
Input or output value. If not set, this value is inferred from messages or documents.
Structured prompt metadata that includes the template and variables used for the LLM input. This should only be used for input IO on LLM spans.
Note: When only input.messages is set for an LLM span, Datadog infers input.value from input.messages and uses the following inference logic:
If a message with role=user exists, the content of the last message is used as input.value.
If a user role message is not present, input.value is inferred by concatenating the content fields of all messages, regardless of their roles.
Message
Field
Type
Description
content [required]
string
The body of the message.
role
string
The role of the entity.
Document
Field
Type
Description
text
string
The text of the document.
name
string
The name of the document.
score
float
The score associated with this document.
id
string
The id of this document.
Prompt
Field
Type
Description
id
string
Logical identifier for this prompt template. Should be unique per ml_app.
version
string
Version tag for the prompt (for example, “1.0.0”). If not provided, LLM Observability automatically generates a version by computing a hash of the template content.
template
string
Single string template form. Use placeholder syntax (like {{variable_name}}) to embed variables. This should not be set with chat_template.
Multi-message template form. Use placeholder syntax (like {{variable_name}}) to embed variables in message content. This should not be set with template.
variables
Dict[key (string), string]
Variables used to render the template. Keys correspond to placeholder names in the template.
query_variable_keys
[string]
Variable keys that contain the user query. Used for hallucination detection.
context_variable_keys
[string]
Variable keys that contain ground-truth or context content. Used for hallucination detection.
tags
Dict[key (string), string]
Tags to attach to the prompt run.
Meta
Field
Type
Description
kind [required]
string
The span kind: "agent", "workflow", "llm", "tool", "task", "embedding", or "retrieval".
Dict[key (string), value] where the value is a float, bool, or string
Data about the span that is not input or output related. Use the following metadata keys for LLM spans: temperature, max_tokens, model_name, and model_provider.
Metrics
Field
Type
Description
input_tokens
float64
The number of input tokens. Only valid for LLM spans.
output_tokens
float64
The number of output tokens. Only valid for LLM spans.
total_tokens
float64
The total number of tokens associated with the span. Only valid for LLM spans.
time_to_first_token
float64
The time in seconds it takes for the first output token to be returned in streaming-based LLM applications. Set for root spans.
time_per_output_token
float64
The time in seconds it takes for the per output token to be returned in streaming-based LLM applications. Set for root spans.
Span
Field
Type
Description
name [required]
string
The name of the span.
span_id [required]
string
An ID unique to the span.
trace_id [required]
string
A unique ID shared by all spans in the same trace.
parent_id [required]
string
ID of the span’s direct parent. If the span is a root span, the parent_id must be undefined.
The session the list of spans belongs to. Can be overridden or set on individual spans as well.
Tag
Tags should be formatted as a list of strings (for example, ["user_handle:dog@gmail.com", "app_version:1.0.0"]). They are meant to store contextual information surrounding the span.