How to send an array of vectors with one api call?

According to Pinecone Documentation “vectors: array of objects, An array containing the vectors to upsert. Recommended batch limit is 100 vectors”

So how to send an array of vectors with one api call?

now I use this code:

},
    "data": {
        "vectors": [
            {
                "values": [
                    1
                ],
                "metadata": {
                    "newKey": "New Value",
                    "newKey-1": "New Value"
                },
                "id": "1"
            }
        ]
    }

but I cant send more than one vector per call

Hi @salemmo409

if you are using an API, just create an array of objects and add them as a parameter it should look something like this in the end:

"data": {
        "vectors": [
            {
                "values": [
                    1
                ],
                "metadata": {
                    "newKey": "New Value",
                    "newKey-1": "New Value"
                },
                "id": "1"
            },
           {
                "values": [
                    2
                ],
                "metadata": {
                    "newKey": "New Value 2",
                    "newKey-1": "New Value 2"
                },
                "id": "2"
           },
// Here just continue adding new vectors
        ]
    }

Python code:


upsert_vectors= []

# vec_id- some string
# embedding - array of floats
# metadata - dict like { "newKey": "New Value", "newKey-1": "New Value" }

upsert_vectors.append((vec_id, embedding, metadata)) # do this to as many as you have

index.upsert(upsert_vectors, namespace="name-space")

For more the documentation have a few examples as well: Insert data

Hope this helps