API Reference

Complete API documentation for Cortex

Exports

Cortex exports the following from the main entry point:

Type Exports

  • VectorStore - The service tag (Effect service identifier)
  • SearchOptions - Options for search queries
  • SearchResult - Individual search result with score and metadata
  • StoredEntry - A stored vector entry with its metadata
  • VectorMetadata - Schema for metadata associated with a vector
  • VectorId - Branded type for vector identifiers

Error Exports

  • VectorStoreError - Base error type
  • VectorNotFoundError - Thrown when a requested entry doesn't exist
  • VectorDecodeError - Thrown when stored data is corrupted

Adapter Exports

  • VectorStoreLive - Layer for the live VectorStore implementation
  • ZVecCollectionLive - Layer for ZVec-backed storage
  • ZVecCollectionConfig - Configuration (dimension, path)
  • InMemoryVectorStoreLive - Layer for in-memory storage (testing)

VectorStore

interface VectorStore {
  store(id: VectorId, vector: Float32Array, metadata: VectorMetadata): Effect<void, VectorStoreErrors>;
  search(queryVector: Float32Array, options: SearchOptions): Effect<SearchResult[], VectorStoreErrors>;
  getEntry(id: VectorId): Effect<StoredEntry, VectorStoreErrors>;
  deleteEntry(id: VectorId): Effect<void, VectorStoreErrors>;
  size: Effect<number, VectorStoreErrors>;
}

Layer Composition

const layer = Layer.provideMerge(VectorStoreLive, Layer.provideMerge(
  ZVecCollectionLive,
  Layer.succeed(ZVecCollectionConfig, { dimension: 128 }),
));

On this page