Skip to main content
POST
/
v1
/
traces
Ingest Traces (OTLP)
curl --request POST \
  --url https://api.promptlayer.com/v1/traces \
  --header 'Content-Type: <content-type>' \
  --header 'X-API-KEY: <api-key>' \
  --data '
{
  "resourceSpans": [
    {
      "resource": {
        "attributes": [
          {
            "key": "<string>",
            "value": {
              "stringValue": "<string>",
              "intValue": "<string>",
              "doubleValue": 123,
              "boolValue": true,
              "arrayValue": {
                "values": [
                  {}
                ]
              }
            }
          }
        ]
      },
      "scopeSpans": [
        {
          "scope": {
            "name": "<string>",
            "version": "<string>"
          },
          "spans": [
            {
              "traceId": "<string>",
              "spanId": "<string>",
              "name": "<string>",
              "startTimeUnixNano": "<string>",
              "parentSpanId": "<string>",
              "endTimeUnixNano": "<string>",
              "attributes": [
                {
                  "key": "<string>",
                  "value": {
                    "stringValue": "<string>",
                    "intValue": "<string>",
                    "doubleValue": 123,
                    "boolValue": true,
                    "arrayValue": {
                      "values": [
                        {}
                      ]
                    }
                  }
                }
              ],
              "status": {
                "message": "<string>"
              },
              "events": [
                {
                  "timeUnixNano": "<string>",
                  "name": "<string>",
                  "attributes": [
                    {
                      "key": "<string>",
                      "value": {
                        "stringValue": "<string>",
                        "intValue": "<string>",
                        "doubleValue": 123,
                        "boolValue": true,
                        "arrayValue": {
                          "values": [
                            {}
                          ]
                        }
                      }
                    }
                  ]
                }
              ],
              "links": [
                {
                  "traceId": "<string>",
                  "spanId": "<string>",
                  "attributes": [
                    {
                      "key": "<string>",
                      "value": {
                        "stringValue": "<string>",
                        "intValue": "<string>",
                        "doubleValue": 123,
                        "boolValue": true,
                        "arrayValue": {
                          "values": [
                            {}
                          ]
                        }
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
'
{
  "partialSuccess": {
    "rejectedSpans": 123,
    "errorMessage": "<string>"
  }
}
Ingest OpenTelemetry traces through PromptLayer’s OTLP/HTTP endpoint.

Behavior Notes

  • This endpoint accepts an ExportTraceServiceRequest as defined by the OpenTelemetry specification.
  • Spans carrying GenAI semantic convention attributes are automatically converted into PromptLayer request logs.
  • Supported content types are application/x-protobuf for binary protobuf encoding and application/json for JSON encoding.
  • Gzip Content-Encoding is supported for both formats.
  • Spans can include promptlayer.prompt.name, optionally with promptlayer.prompt.version, to link the generated request log to an existing prompt template in your workspace.
  • Spans can include user.id/enduser.id, gen_ai.conversation.id/session.id, and promptlayer.metadata.* attributes to attach searchable user identity and metadata to the generated request log.
  • For SDK setup, GenAI semantic conventions, prompt template linking, metadata, and collector configuration, see OpenTelemetry.

Authorizations

X-API-KEY
string
header
required

Headers

Content-Type
enum<string>
required

The encoding of the request body. Use application/x-protobuf for binary protobuf or application/json for JSON.

Available options:
application/x-protobuf,
application/json
Content-Encoding
enum<string>

Set to gzip if the request body is gzip-compressed.

Available options:
gzip

Query Parameters

close_after
boolean
default:false

When true, all trace IDs in the request are marked as closed after ingestion. Subsequent span writes for those traces will be rejected with HTTP 409. Defaults to false.

Body

An OTLP ExportTraceServiceRequest in JSON encoding. See the OTLP specification for the full schema.

resourceSpans
object[]

An array of ResourceSpans. Each element describes spans from a single instrumented resource.

Response

Successful Response. When using protobuf, the response is a binary ExportTraceServiceResponse. When using JSON, the response is a JSON object.

Response to an OTLP trace export request.

partialSuccess
object

Present only when some spans were rejected. Null when all spans were accepted.