Skip to main content
Adds new vectors to the encrypted index or updates existing vectors if they have the same ID. This operation supports two distinct calling patterns for maximum flexibility.

Method Overloads

Pattern 1: VectorItem Array

Parameters

Pattern 1: VectorItem Array

Pattern 2: Parallel Arrays

Passing a Float32Array automatically uses an optimized binary transfer format for better performance with large batches.

VectorItem Structure

Each VectorItem must contain an id and vector, with optional fields:
The contents field accepts both strings and Buffers. All contents are encoded to bytes and encrypted before storage, and will be returned as decoded UTF-8 strings when retrieved with get().

Returns

Promise<UpsertResponse>: A Promise that resolves to a response object containing the operation status, message, and count of upserted vectors. See the UpsertResponse type for more details.

Exceptions

  • Throws if the API request fails due to network connectivity issues.
  • Throws if authentication fails (invalid API key).
  • Throws if the encryption key is invalid for the specified index.
  • Throws if there are internal server errors preventing the upsert.
  • Throws detailed validation errors for invalid VectorItem objects.
  • Throws if vector dimensions don’t match the index configuration.
  • Throws if required fields are missing from vector items.
  • Throws if array lengths don’t match in parallel array format.
  • Throws if vector elements are not finite numbers.

Example Usage

Pattern 2: Parallel Arrays (For Bulk Operations)

Pattern 2 (Binary Fast Path): Float32Array

For large batches, pack vectors into a single Float32Array and pass it as vectors. The SDK detects the typed array and uses an optimized binary transfer (no per-vector JSON encoding), which substantially reduces wire size and CPU on both ends.
Use Float32Array whenever you already have vectors in a typed buffer (e.g. from a model output, an ArrayBuffer over a socket, or an embedding library that exposes Float32Array directly). Avoid the cost of converting back to number[][].

Updating Existing Vectors

Batch Processing with Error Handling

Response Format