openapi: 3.0.1 info: title: PromptLayer Evaluations & Datasets Spans & Traces API description: 'REST API for PromptLayer, a prompt engineering, prompt management, and LLM observability platform. The API logs and tracks LLM requests, manages a versioned prompt registry with release labels, ingests OpenTelemetry-style spans and traces, and runs evaluations against datasets. All requests are authenticated with an `X-API-KEY` header. Note: some legacy tracking endpoints are served under the `/rest` path prefix while newer endpoints are served at the API root.' termsOfService: https://www.promptlayer.com/terms-of-service contact: name: PromptLayer Support email: hello@promptlayer.com version: '1.0' servers: - url: https://api.promptlayer.com security: - ApiKeyAuth: [] tags: - name: Spans & Traces description: Ingest spans and manage traces for LLM observability. paths: /spans-bulk: post: operationId: createSpansBulk tags: - Spans & Traces summary: Ingest spans in bulk description: Atomically ingests a batch of OpenTelemetry-style spans. Optional per-span `log_request` payloads create associated request logs. If any span fails, the entire batch is rolled back. requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/SpansBulkRequest' responses: '201': description: Spans ingested content: application/json: schema: $ref: '#/components/schemas/SpansBulkResponse' '401': description: Unauthorized '422': description: Validation error /otlp/v1/traces: post: operationId: ingestOtlpTraces tags: - Spans & Traces summary: Ingest OTLP traces description: OpenTelemetry Protocol (OTLP) HTTP endpoint for ingesting traces. requestBody: required: true content: application/json: schema: type: object additionalProperties: true responses: '200': description: Traces accepted '401': description: Unauthorized /traces/{id}: get: operationId: getTrace tags: - Spans & Traces summary: Get a trace parameters: - name: id in: path required: true schema: type: string responses: '200': description: A trace content: application/json: schema: $ref: '#/components/schemas/Trace' '401': description: Unauthorized '404': description: Not found /traces/{id}/close: post: operationId: closeTrace tags: - Spans & Traces summary: Close a trace description: Closes an open trace so no further spans can be appended. parameters: - name: id in: path required: true schema: type: string responses: '200': description: Trace closed content: application/json: schema: $ref: '#/components/schemas/SuccessMessage' '401': description: Unauthorized '404': description: Not found components: schemas: PromptBlueprint: type: object description: Prompt Blueprint payload, either a chat prompt (messages array) or a completion prompt (content string). Provider-agnostic representation. additionalProperties: true Trace: type: object properties: id: type: string name: type: string spans: type: array items: $ref: '#/components/schemas/Span' closed: type: boolean Span: type: object properties: name: type: string context: type: object properties: trace_id: type: string span_id: type: string trace_state: type: string kind: type: string enum: - SpanKind.CLIENT - SpanKind.CONSUMER - SpanKind.INTERNAL - SpanKind.PRODUCER - SpanKind.SERVER parent_id: type: string nullable: true start_time: type: integer description: Start time in nanoseconds. end_time: type: integer description: End time in nanoseconds. status: type: object properties: status_code: type: string enum: - StatusCode.OK - StatusCode.ERROR - StatusCode.UNSET description: type: string nullable: true attributes: type: object additionalProperties: true resource: type: object properties: attributes: type: object additionalProperties: true schema_url: type: string log_request: $ref: '#/components/schemas/LogRequest' SpansBulkRequest: type: object required: - spans properties: spans: type: array items: $ref: '#/components/schemas/Span' close_after: type: boolean default: false SuccessMessage: type: object properties: success: type: boolean message: type: string SpansBulkResponse: type: object properties: success: type: boolean spans: type: array items: type: object properties: id: type: integer name: type: string span_id: type: string request_logs: type: array items: type: object properties: id: type: integer span_id: type: string rejected_span_ids: type: array nullable: true items: type: string rejected_trace_ids: type: array nullable: true items: type: string rejection_reason: type: string nullable: true LogRequest: type: object required: - provider - model - input - output - request_start_time - request_end_time properties: provider: type: string description: LLM provider name (e.g., openai, anthropic). model: type: string description: Model identifier. input: $ref: '#/components/schemas/PromptBlueprint' output: $ref: '#/components/schemas/PromptBlueprint' request_start_time: type: string format: date-time request_end_time: type: string format: date-time api_type: type: string description: API endpoint type (e.g., chat-completions). parameters: type: object additionalProperties: true description: Model parameters such as temperature and max_tokens. tags: type: array items: type: string metadata: type: object additionalProperties: type: string status: type: string enum: - SUCCESS - WARNING - ERROR default: SUCCESS error_type: type: string error_message: type: string maxLength: 1024 input_tokens: type: integer output_tokens: type: integer price: type: number score: type: integer minimum: 0 maximum: 100 securitySchemes: ApiKeyAuth: type: apiKey in: header name: X-API-KEY