Skip to main content
Adds vectors to the index, or replaces existing vectors with the same ID. upsert() takes either an array of items or parallel arrays:

Parameters

Shape 1: items

Each item can contain: Strings in contents are stored as-is; bytes are base64-encoded first. get() always returns contents as a string, so bytes come back as their base64 text.
Store dates in metadata as epoch milliseconds (date.getTime()) so range filters work on them. See Dates.

Shape 2: parallel arrays

Don’t upsert vectors containing NaN or infinite values. The service stores them, and later get or query calls on that index that return vectors or distances fail with a 5xx error.

Returns

Promise<UpsertResponse> with status and message, e.g. { status: 'success', message: 'Upserted 2 vectors' }. An empty items array returns { status: 'success', message: 'No items to upsert' } without calling the service.

Exceptions

  • The input matches neither shape, arrays differ in length, or an items or number[][] vector contains a non-finite number. Thrown before any request is sent. Float32Array input isn’t checked.
  • The service rejects the items (HTTP 400), for example a vector with the wrong dimension.
The indexKey or apiKey is invalid, or a read-only user key is used (HTTP 401/403).
The service returns 5xx.
See Errors for the full hierarchy.

Example Usage

Items

Parallel arrays

Float32Array (binary)

Use a Float32Array when the vectors already come from a model or buffer in that form.

Replace an existing item