JSON Type Definitions
CyborgDB provides strongly-typed JSON types for improved type safety when working with metadata and other JSON-serializable data.JsonPrimitive
JsonValue
JsonObject
JsonArray
VectorMetadata
Example Usage
CreateIndexRequest
TheCreateIndexRequest interface defines the parameters for creating a new encrypted index.
Properties
Example Usage
v0.17 removed the polymorphic
indexConfig and the associated IndexIVFFlat / IndexIVFPQ / IndexIVFSQ model types — there is now a single DiskIVF index type. Configuration parameters are flat fields on CreateIndexRequest.The
createIndex() method on the Client class accepts a Uint8Array for indexKey and automatically converts it to a hex-encoded string for the request. The CreateIndexRequest model itself uses the hex-encoded string type.UpsertRequest
Interface for adding or updating vectors in an encrypted index.Properties
Example Usage
QueryRequest
Interface for performing similarity search in the encrypted index.Properties
Example Usage
BatchQueryRequest
Interface for performing batch similarity searches with multiple vectors.Properties
Example Usage
TrainRequest
Interface for training an index to optimize query performance.Properties
Example Usage
DeleteRequest
Interface for deleting vectors from the encrypted index.Properties
Example Usage
GetRequest
Interface for retrieving specific vectors from the index.Properties
Example Usage
VectorItem
Class representing a vectorized item for storage in the encrypted index.Properties
Example Usage
Index Configuration
v0.17 introduces a single DiskIVF index type. The polymorphic
IndexIVFFlat / IndexIVFPQ / IndexIVFSQ interfaces have been removed — there is no IndexConfig discriminated-union type any more. Configuration is expressed as flat fields on CreateIndexRequest / Client.createIndex().Key Management
At least one of
indexKey / kmsName must be supplied. Supplying both against a real-KMS slot is rejected by the server.
Response Types
UpsertResponse
Response interface for upsert operations.Properties
Example Usage
DeleteResponse
Response interface for delete operations.Properties
Example Usage
TrainResponse
Response interface for training operations.Properties
Example Usage
HealthResponse
Response interface for health check operations.Properties
Example Usage
Training status
There is no publicTrainingStatus type in v0.17. Use index.isTraining() on an EncryptedIndex instance — it returns a Promise<boolean> indicating whether this index is currently being trained (or queued for training) on the server.
/v1/indexes/training-status endpoint and tests whether the index name is in the returned trainingIndexes list. The full server-side response shape (trainingIndexes, retrainThreshold, currentlyTraining, queuedIndexes, workerRunning) is the OpenAPI-generated IndexTrainingStatusResponseModel and is not part of the SDK’s public surface.
GetResponseModel
Response class for vector retrieval operations.Properties
GetResultItem
Enhanced type-safe result item for get operations. This type extendsGetResultItemModel with proper typing for metadata and contents fields.
Properties
Example Usage
QueryResponse
Response class for similarity search operations.Properties
Example Usage
QueryResultItem
Class representing a single result from similarity search.Properties
Error Types
ErrorResponseModel
Standard error response class for API errors.Properties
HTTPValidationError
Class for validation errors with detailed field information.Properties
Metadata Filtering
Thefilters parameter in query operations supports a subset of MongoDB query operators for flexible metadata filtering:
Supported Operators
$eq: Equality ({ "category": "research" })$ne: Not equal ({ "status": { "$ne": "draft" } })$gt: Greater than ({ "score": { "$gt": 0.8 } })$gte: Greater than or equal ({ "year": { "$gte": 2020 } })$lt: Less than ({ "price": { "$lt": 100 } })$lte: Less than or equal ({ "rating": { "$lte": 4.5 } })$in: In array ({ "tag": { "$in": ["ai", "ml"] } })$nin: Not in array ({ "category": { "$nin": ["spam", "deleted"] } })$and: Logical AND ({ "$and": [{"a": 1}, {"b": 2}] })$or: Logical OR ({ "$or": [{"x": 1}, {"y": 2}] })
Filter Examples
Field Selection
Many operations support field selection through theinclude parameter:
Available Fields
vector: The vector data itselfcontents: Text or binary content associated with the vectormetadata: Structured metadata objectdistance: Similarity distance (query operations only)
Example Usage
Filter Types
FilterExpression
FilterValue
FilterOperator
Example Usage
Utility Functions
The SDK provides type guard and utility functions for safer type checking and error handling.isJsonValue
Parameters
Returns
boolean: Returns true if the value is a valid JSON value, false otherwise.
Example Usage
isError
Parameters
Returns
boolean: Returns true if the value is an Error instance, false otherwise.
Example Usage
getErrorMessage
Parameters
Returns
string: A string message extracted from the error. Returns the error’s message property if it’s an Error, converts to string otherwise.