Upsert Vectors
Insert new documents or update existing documents in a vector store.
Upsert Behavior: If a document ID already exists, it will be completely replaced with the new content and metadata. The previous document’s text, embedding, and all metadata fields are discarded. If the ID does not exist, a new document is created.
Document Content: Each document supports several modes:
contentonly: text is automatically embedded using the store’s configured model.embeddingonly: pre-computed embedding vector is used directly. Dimension must match the store’s configuration.- Both
contentandembedding: the pre-computed embedding is stored and text is kept for retrieval/search. - Neither (metadata-only): only metadata is updated on an existing document without re-embedding. If the document does not exist, it will appear as a failure in the batch response.
A store created without an embedding model (dimensions-only) only accepts documents with pre-computed embedding.
Batch Operations: This endpoint supports batch operations with partial success handling and mixed document types (some with raw embeddings, some with content) in the same call.
Metadata: Supports nested metadata with string, number, boolean, object, and array types. Null values are not permitted—omit the field or use an empty string instead.
Upsert Vectors
import os
from scale_gp_beta import SGPClient
client = SGPClient(
api_key=os.environ.get("SGP_API_KEY"), # This is the default and can be omitted
)
response = client.vector_stores.upsert(
vector_store_name="vector_store_name",
vectors=[{
"id": "id"
}],
)
print(response.failure_count){
"failure_count": 0,
"success_count": 0,
"failed": [
{
"id": "id",
"error": "error"
}
],
"succeeded": [
"string"
]
}Returns Examples
{
"failure_count": 0,
"success_count": 0,
"failed": [
{
"id": "id",
"error": "error"
}
],
"succeeded": [
"string"
]
}