{
  "openapi": "3.1.1",
  "info": {
    "title": "laminar",
    "description": "",
    "license": {
      "name": ""
    },
    "version": "0.1.0"
  },
  "servers": [
    {
      "url": "https://api.lmnr.ai"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/queues/push": {
      "post": {
        "tags": [
          "api::queues"
        ],
        "operationId": "push_to_queue",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QueuePushRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Queue push response",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Items uploaded successfully."
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Cannot parse the JSON payload into a valid request.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "JSON deserialize error."
                }
              }
            }
          },
          "404": {
            "description": "Queue not found. `queueName` is not found within the project defined by project API key.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Queue not found."
                }
              }
            }
          }
        }
      }
    },
    "/v1/evals": {
      "post": {
        "tags": [
          "api::evaluations"
        ],
        "operationId": "init_eval",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InitEvalRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Evaluation created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InitEvalResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Cannot parse the JSON payload into a valid request.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "JSON deserialize error."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Project API key is invalid.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Invalid project API key."
                }
              }
            }
          }
        }
      }
    },
    "/v1/evals/{eval_id}/datapoints": {
      "post": {
        "tags": [
          "api::evaluations"
        ],
        "operationId": "save_eval_datapoints",
        "parameters": [
          {
            "name": "eval_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The UUID of the evaluation"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SaveEvalDatapointsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Evaluation datapoints saved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "uuid",
                  "description": "The UUID of the evaluation"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Cannot parse the JSON payload into a valid request.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "JSON deserialize error."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Project API key is invalid.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Invalid project API key."
                }
              }
            }
          },
          "404": {
            "description": "Evaluation not found.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Evaluation not found."
                }
              }
            }
          }
        }
      }
    },
    "/v1/evals/{eval_id}/datapoints/{datapoint_id}": {
      "post": {
        "tags": [
          "api::evaluations"
        ],
        "operationId": "update_eval_datapoint",
        "parameters": [
          {
            "name": "eval_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The UUID of the evaluation"
          },
          {
            "name": "datapoint_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The UUID of the datapoint"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateEvalDatapointRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Evaluation datapoint updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string",
                  "format": "uuid",
                  "description": "The UUID of the datapoint"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Cannot parse the JSON payload into a valid request.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "JSON deserialize error."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Project API key is invalid.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Invalid project API key."
                }
              }
            }
          },
          "404": {
            "description": "Evaluation or datapoint not found.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Evaluation or datapoint not found."
                }
              }
            }
          }
        }
      }
    },
    "/v1/evaluators/score": {
      "post": {
        "tags": [
          "api::evaluators"
        ],
        "operationId": "create_evaluator_score",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEvaluatorScoreRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Evaluator score created successfully"
          },
          "400": {
            "description": "Bad request. Cannot parse the JSON payload into a valid request."
          },
          "401": {
            "description": "Unauthorized. Project API key is invalid.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Invalid project API key."
                }
              }
            }
          },
          "404": {
            "description": "No matching spans found.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "No matching spans found"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sql/query": {
      "post": {
        "tags": [
          "api::sql"
        ],
        "operationId": "sql_query",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SqlQueryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "SQL query executed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SqlQueryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request. Cannot parse the JSON payload into a valid request.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "JSON deserialize error."
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized. Project API key is invalid.",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string",
                  "example": "Invalid project API key."
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "QueuePushItem": {
        "type": "object",
        "required": [],
        "properties": {
          "id": {
            "description": "Unique datapoint ID. If not specified, a UUID v4 will be generated.",
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "description": "Name of the datapoint. If not specified, an empty string is used.",
            "type": "string"
          },
          "input": {
            "description": "Input of the datapoint. Can be any JSON value. Defaults to null."
          },
          "output": {
            "description": "Output of the datapoint. Can be any JSON value. Defaults to null."
          },
          "attributes": {
            "description": "Attributes of the datapoint. Can be any JSON object. Defaults to an empty object.",
            "type": "object"
          }
        }
      },
      "QueuePushRequest": {
        "type": "object",
        "required": ["items", "queueName"],
        "properties": {
          "items": {
            "type": "array",
            "description": "List of datapoints to push to the queue.",
            "items": {
              "$ref": "#/components/schemas/QueuePushItem"
            }
          },
          "queueName": {
            "description": "Name of the queue to push to. Must be an existing queue.",
            "type": "string"
          }
        }
      },
      "InitEvalRequest": {
        "type": "object",
        "required": [],
        "properties": {
          "name": {
            "description": "Name of the evaluation. If not specified, a random name will be generated.",
            "type": "string"
          },
          "groupName": {
            "description": "Group name for the evaluation. Defaults to 'default'.",
            "nullable": true,
            "type": "string"
          }
        }
      },
      "InitEvalResponse": {
        "type": "object",
        "required": ["id", "name", "projectId", "groupName"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "The unique identifier of the evaluation"
          },
          "name": {
            "type": "string",
            "description": "The name of the evaluation"
          },
          "projectId": {
            "type": "string",
            "format": "uuid",
            "description": "The project ID this evaluation belongs to"
          },
          "groupName": {
            "type": "string",
            "description": "The group name of the evaluation"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When the evaluation was created"
          }
        }
      },
      "EvaluationDatapointResult": {
        "type": "object",
        "required": ["data"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique datapoint ID. If not specified, a UUID v4 will be generated."
          },
          "data": {
            "description": "Input data of the datapoint. Can be any JSON value."
          },
          "index": {
            "type": "integer",
            "description": "Index of the datapoint. Defaults to 0.",
            "default": 0
          },
          "target": {
            "description": "Target/expected output of the datapoint. Can be any JSON value."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Additional metadata for the datapoint. Defaults to empty object.",
            "nullable": true
          },
          "executorOutput": {
            "description": "Executor output of the datapoint. Can be any JSON value.",
            "nullable": true
          },
          "traceId": {
            "type": "string",
            "format": "uuid", 
            "description": "Trace ID associated with the datapoint. If not specified, a UUID v4 will be generated."
          },
          "scores": {
            "type": "object",
            "additionalProperties": {
              "type": "number",
              "nullable": true
            },
            "description": "Scores for the datapoint as key-value pairs",
            "default": {}
          }
        }
      },
      "SaveEvalDatapointsRequest": {
        "type": "object",
        "required": ["points"],
        "properties": {
          "groupName": {
            "description": "Group name for the evaluation datapoints. Defaults to 'default'.",
            "type": "string"
          },
          "points": {
            "type": "array",
            "description": "List of evaluation datapoint results to save.",
            "items": {
              "$ref": "#/components/schemas/EvaluationDatapointResult"
            }
          }
        }
      },
      "UpdateEvalDatapointRequest": {
        "type": "object",
        "required": ["scores"],
        "properties": {
          "executorOutput": {
            "description": "Updated executor output of the datapoint. Can be any JSON value.",
            "nullable": true
          },
          "scores": {
            "type": "object",
            "additionalProperties": {
              "type": "number",
              "nullable": true
            },
            "description": "Updated scores for the datapoint as key-value pairs."
          }
        }
      },
      "CreateEvaluatorScoreBase": {
        "type": "object",
        "required": ["name", "score", "source"],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the evaluator score"
          },
          "score": {
            "type": "number",
            "description": "The score value (float)"
          },
          "source": {
            "type": "string",
            "enum": ["Code", "Evaluator"],
            "description": "Source of the score"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Additional metadata for the score",
            "nullable": true
          }
        }
      },
      "CreateEvaluatorScoreRequestWithTraceId": {
        "type": "object",
        "required": ["name", "score", "source", "traceId"],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the evaluator score"
          },
          "score": {
            "type": "number",
            "description": "The score value (float)"
          },
          "source": {
            "type": "string",
            "enum": ["Code", "Evaluator"],
            "description": "Source of the score"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Additional metadata for the score",
            "nullable": true
          },
          "traceId": {
            "type": "string",
            "format": "uuid",
            "description": "The trace ID to score (will be attached to root span)"
          }
        }
      },
      "CreateEvaluatorScoreRequestWithSpanId": {
        "type": "object",
        "required": ["name", "score", "source", "spanId"],
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the evaluator score"
          },
          "score": {
            "type": "number",
            "description": "The score value (float)"
          },
          "source": {
            "type": "string",
            "enum": ["Code", "Evaluator"],
            "description": "Source of the score"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Additional metadata for the score",
            "nullable": true
          },
          "spanId": {
            "type": "string",
            "format": "uuid",
            "description": "The span ID to score"
          }
        }
      },
      "CreateEvaluatorScoreRequest": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/CreateEvaluatorScoreRequestWithTraceId",
            "description": "Create evaluator score with trace ID"
          },
          {
            "$ref": "#/components/schemas/CreateEvaluatorScoreRequestWithSpanId",
            "description": "Create evaluator score with span ID"
          }
        ]
      },
      "LaminarSpanContext": {
        "type": "object",
        "required": ["traceId", "spanId"],
        "properties": {
          "traceId": {
            "type": "string",
            "description": "OpenTelemetry trace ID in the UUID format."
          },
          "spanId": {
            "type": "string",
            "description": "OpenTelemetry span ID in the UUID format."
          },
          "isRemote": {
            "type": "boolean",
            "description": "Whether the span is remote."
          }
        }
      },
      "SqlQueryRequest": {
        "type": "object",
        "required": ["query"],
        "properties": {
          "query": {
            "type": "string",
            "description": "The SQL query to execute.",
            "example": "SELECT name, input_tokens FROM spans WHERE start_time > now() - interval '1 hour' LIMIT 10"
          }
        }
      },
      "SqlQueryResponse": {
        "type": "object",
        "required": ["data"],
        "properties": {
          "data": {
            "type": "array",
            "description": "The data returned from the SQL query.",
            "example": [
              {
                "name": "workflow",
                "input_tokens": 0
              },
              {
                "name": "openai.chat",
                "input_tokens": 369
              }
            ]
          }
        }
      }
    }
  }
}
