{
  "openapi": "3.0.1",
  "info": {
    "title": "Self Learning Postgres DB",
    "description": "Self-learning vector database with GNN-powered index optimization. Features: vector search, RAG queries, embeddings, clustering, deduplication, batch ops, and data import/export. Scales with Raft consensus.",
    "version": "2.1",
    "x-build-id": "LfI2tK0RJa7uPN8NB"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/ruv~self-learning-postgres-db/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-ruv-self-learning-postgres-db",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/ruv~self-learning-postgres-db/runs": {
      "post": {
        "operationId": "runs-sync-ruv-self-learning-postgres-db",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/ruv~self-learning-postgres-db/run-sync": {
      "post": {
        "operationId": "run-sync-ruv-self-learning-postgres-db",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "required": [
          "action"
        ],
        "properties": {
          "action": {
            "title": "Action",
            "enum": [
              "full_workflow",
              "search",
              "insert",
              "batch_insert",
              "get",
              "list",
              "update",
              "delete",
              "upsert",
              "hybrid_search",
              "multi_query_search",
              "mmr_search",
              "graph_search",
              "range_search",
              "batch_search",
              "create_table",
              "drop_table",
              "list_tables",
              "table_stats",
              "create_index",
              "reindex",
              "train_gnn",
              "optimize_index",
              "analyze_patterns",
              "sona_learn",
              "sona_status",
              "cluster",
              "find_duplicates",
              "deduplicate",
              "export",
              "import",
              "rag_query",
              "summarize",
              "ping",
              "version",
              "embedding_models",
              "generate_embedding",
              "similarity"
            ],
            "type": "string",
            "description": "The operation to perform on the vector database",
            "default": "full_workflow"
          },
          "connectionString": {
            "title": "Database Connection",
            "type": "string",
            "description": "PostgreSQL connection URL. Leave empty for embedded database (non-persistent). For persistent storage, use your own PostgreSQL with ruvector/pgvector extension."
          },
          "tableName": {
            "title": "Table/Collection Name",
            "type": "string",
            "description": "Name of the vector table (collection)",
            "default": "documents"
          },
          "query": {
            "title": "Search Query",
            "type": "string",
            "description": "Natural language query for semantic search. The AI understands meaning, not just keywords."
          },
          "queryVector": {
            "title": "Query Vector",
            "type": "array",
            "description": "Pre-computed embedding vector (alternative to query text). Use with external embedding APIs."
          },
          "documents": {
            "title": "Documents",
            "type": "array",
            "description": "Documents to insert. Each should have 'content' and optional 'metadata' and 'embedding'."
          },
          "topK": {
            "title": "Number of Results",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Maximum number of results to return",
            "default": 10
          },
          "distanceMetric": {
            "title": "Distance Metric",
            "enum": [
              "cosine",
              "l2",
              "inner_product",
              "manhattan"
            ],
            "type": "string",
            "description": "How to measure vector similarity",
            "default": "cosine"
          },
          "filter": {
            "title": "Filter",
            "type": "string",
            "description": "SQL WHERE clause for filtering. Example: metadata->>'category' = 'AI'"
          },
          "minScore": {
            "title": "Minimum Score",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "Minimum similarity score threshold (0-1)",
            "default": 0
          },
          "maxDistance": {
            "title": "Maximum Distance",
            "type": "number",
            "description": "Maximum distance threshold for range search"
          },
          "includeEmbeddings": {
            "title": "Include Embeddings",
            "type": "boolean",
            "description": "Include embedding vectors in results (increases response size)",
            "default": false
          },
          "includeMetadata": {
            "title": "Include Metadata",
            "type": "boolean",
            "description": "Include metadata in results",
            "default": true
          },
          "embeddingModel": {
            "title": "Embedding Model",
            "enum": [
              "all-MiniLM-L6-v2",
              "bge-small-en-v1.5",
              "bge-base-en-v1.5",
              "nomic-embed-text-v1",
              "gte-small",
              "e5-small-v2"
            ],
            "type": "string",
            "description": "AI model for generating text embeddings. No API key needed - runs locally!",
            "default": "all-MiniLM-L6-v2"
          },
          "generateEmbeddings": {
            "title": "Generate Embeddings",
            "type": "boolean",
            "description": "Auto-generate embeddings for documents without them",
            "default": true
          },
          "dimensions": {
            "title": "Vector Dimensions",
            "minimum": 64,
            "maximum": 4096,
            "type": "integer",
            "description": "Embedding dimensions (384 for MiniLM/BGE-small, 768 for larger models)",
            "default": 384
          },
          "indexType": {
            "title": "Index Type",
            "enum": [
              "hnsw",
              "ivfflat",
              "none"
            ],
            "type": "string",
            "description": "Vector index algorithm for faster search",
            "default": "hnsw"
          },
          "hnswM": {
            "title": "HNSW M Parameter",
            "minimum": 4,
            "maximum": 64,
            "type": "integer",
            "description": "Max connections per node. Higher = better recall, more memory",
            "default": 16
          },
          "hnswEfConstruction": {
            "title": "HNSW ef_construction",
            "minimum": 16,
            "maximum": 512,
            "type": "integer",
            "description": "Index build quality. Higher = better index, slower build",
            "default": 64
          },
          "hnswEfSearch": {
            "title": "HNSW ef_search",
            "minimum": 16,
            "maximum": 512,
            "type": "integer",
            "description": "Search quality. Higher = better recall, slower search",
            "default": 100
          },
          "ivfLists": {
            "title": "IVF Lists",
            "minimum": 10,
            "maximum": 1000,
            "type": "integer",
            "description": "Number of IVF partitions for IVFFlat index",
            "default": 100
          },
          "hybridWeight": {
            "title": "Hybrid Weight",
            "minimum": 0,
            "maximum": 1,
            "type": "number",
            "description": "Balance between vector (1.0) and keyword (0.0) search",
            "default": 0.7
          },
          "batchSize": {
            "title": "Batch Size",
            "minimum": 1,
            "maximum": 1000,
            "type": "integer",
            "description": "Documents per batch for batch operations",
            "default": 100
          },
          "documentId": {
            "title": "Document ID",
            "type": "integer",
            "description": "Single document ID for get/update/delete operations"
          },
          "documentIds": {
            "title": "Document IDs",
            "type": "array",
            "description": "Multiple document IDs for batch delete"
          },
          "updates": {
            "title": "Updates",
            "type": "object",
            "description": "Fields to update: {content, metadata, embedding}"
          },
          "enableLearning": {
            "title": "Enable Learning",
            "type": "boolean",
            "description": "Enable self-learning index optimization",
            "default": false
          },
          "learningRate": {
            "title": "Learning Rate",
            "minimum": 0.0001,
            "maximum": 1,
            "type": "number",
            "description": "GNN training learning rate",
            "default": 0.01
          },
          "gnnLayers": {
            "title": "GNN Layers",
            "minimum": 1,
            "maximum": 10,
            "type": "integer",
            "description": "Number of Graph Neural Network layers",
            "default": 2
          },
          "trainEpochs": {
            "title": "Training Epochs",
            "minimum": 1,
            "maximum": 100,
            "type": "integer",
            "description": "Number of GNN training epochs",
            "default": 10
          },
          "numClusters": {
            "title": "Number of Clusters",
            "minimum": 2,
            "maximum": 100,
            "type": "integer",
            "description": "K-means cluster count",
            "default": 10
          },
          "clusteringAlgorithm": {
            "title": "Clustering Algorithm",
            "enum": [
              "kmeans",
              "hierarchical"
            ],
            "type": "string",
            "description": "Clustering method",
            "default": "kmeans"
          },
          "similarityThreshold": {
            "title": "Similarity Threshold",
            "minimum": 0.5,
            "maximum": 1,
            "type": "number",
            "description": "Threshold for duplicate detection (0-1, higher = stricter)",
            "default": 0.95
          },
          "exportFormat": {
            "title": "Export Format",
            "enum": [
              "json",
              "csv"
            ],
            "type": "string",
            "description": "Data export format",
            "default": "json"
          },
          "importData": {
            "title": "Import Data",
            "type": "array",
            "description": "Data to import (array of documents with content and optional metadata)"
          },
          "ragMaxTokens": {
            "title": "RAG Max Tokens",
            "minimum": 100,
            "maximum": 10000,
            "type": "integer",
            "description": "Maximum context tokens for RAG query",
            "default": 2000
          },
          "ragContext": {
            "title": "RAG Context",
            "type": "string",
            "description": "Additional context to prepend to RAG results"
          },
          "sonaEnabled": {
            "title": "Enable SONA Learning",
            "type": "boolean",
            "description": "Enable TRM/SONA self-learning with trajectory tracking and pattern recognition",
            "default": true
          },
          "ewcLambda": {
            "title": "EWC Lambda",
            "minimum": 100,
            "maximum": 10000,
            "type": "number",
            "description": "Elastic Weight Consolidation strength for anti-forgetting protection. Higher values preserve more learned knowledge.",
            "default": 2000
          },
          "patternThreshold": {
            "title": "Pattern Threshold",
            "minimum": 0.1,
            "maximum": 1,
            "type": "number",
            "description": "Minimum confidence threshold for pattern recognition (0-1)",
            "default": 0.7
          },
          "maxTrajectories": {
            "title": "Max Trajectories",
            "minimum": 10,
            "maximum": 1000,
            "type": "integer",
            "description": "Maximum number of trajectory steps to track for learning",
            "default": 100
          },
          "sonaLearningTiers": {
            "title": "Learning Tiers",
            "type": "array",
            "description": "SONA learning tiers to enable (instant=real-time, background=async, deep=comprehensive)",
            "default": [
              "instant",
              "background"
            ]
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}