Reference
Create Spans Bulk
POST
Create multiple spans in bulk with optional log request for each span. This endpoint is used for creating observability spans from telemetry data.
Request Body
The request body must contain a spans
array, where each span can optionally include a log_request
field to simultaneously create a request log associated with the span.
Span Fields
- name (string, required): The name of the span
- context (object, required): Contains trace_id, span_id, and trace_state
- kind (enum, required): One of SpanKind.CLIENT, SpanKind.CONSUMER, SpanKind.INTERNAL, SpanKind.PRODUCER, SpanKind.SERVER
- parent_id (string, optional): The ID of the parent span
- start_time (integer, required): Start time in nanoseconds since epoch
- end_time (integer, required): End time in nanoseconds since epoch
- status (object, required): Contains status_code (StatusCode.ERROR, StatusCode.OK, StatusCode.UNSET) and optional description
- attributes (object, required): Key-value pairs of span attributes
- events (array, optional): Array of span events
- links (array, optional): Array of span links
- resource (object, required): Contains attributes object and schema_url
- log_request (object, optional): Optional request log data to create alongside the span
Log Request Fields (Optional)
When included, the log_request
field creates a request log associated with the span:
- provider (string, required): The LLM provider (e.g., “openai”, “anthropic”)
- model (string, required): The model name
- input (object, required): The input template (chat or completion format)
- output (object, required): The output template (chat or completion format)
- request_start_time (datetime, required): ISO format datetime
- request_end_time (datetime, required): ISO format datetime
- parameters (object, optional): Model parameters used
- tags (array[string], optional): Tags to associate with the request
- metadata (object, optional): Metadata key-value pairs
- prompt_name (string, optional): Name of the prompt template
- prompt_version_number (integer, optional): Version number of the prompt
- prompt_input_variables (object, optional): Variables used in the prompt
- input_tokens (integer, optional): Number of input tokens
- output_tokens (integer, optional): Number of output tokens
- price (float, optional): Cost of the request
- function_name (string, optional): Name of the function called
- score (integer, optional): Score between 0-100
Response
Returns a JSON object with:
- success (boolean): Whether the operation succeeded
- spans (array): Array of created span objects
- request_logs (array, optional): Array of created request log objects (only present if log_request was provided)
Example Request
Notes
- Spans with names “openai.OpenAI” or “anthropic.Anthropic” are excluded from processing
- When
log_request
is provided, the created request log will be associated with the span via the span_id - If a prompt_name is specified but not found, the span will still be created but the log_request creation will be skipped for that span
- All operations are atomic - if any span creation fails, the entire batch is rolled back
Headers
API key to authorize the operation.
Body
application/json
Response
201
application/json
Successful Response
The response is of type object
.