Method Overloads
Pattern 1: VectorItem Array
Parameters
Pattern 1: VectorItem Array
Pattern 2: Parallel Arrays
VectorItem Structure
EachVectorItem must contain an id and vector, with optional fields:
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
Error
Error
- 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.
Validation Errors
Validation Errors
- 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 1: VectorItem Array (Recommended)
Pattern 2: Parallel Arrays (For Bulk Operations)
Pattern 2 (Binary Fast Path): Float32Array
For large batches, pack vectors into a singleFloat32Array 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.