upsertRequest was null or undefined when calling upsert

Trying to do an upsert using the node client and getting an error:


Code is as follows:

async function saveEmbeddings(documents) {
  const vectors = => {
    return {
      id: doc.metadata.source.replace(/-/g, '_'),
      values: doc.embedding,
      metadata: { topic: doc.metadata.source, source: folder }

/* [ {
    id: '40-character-string',
    values: [...1536 values],
    metadata: {
      topic: '40-character-string',
      source: 'Book'

  const results = await pineconeIndex.upsert({ vectors });
//error here

Seems odd because upsertRequest certainly isn't null. Any thoughts? Everything else seems to work.


your example looks good to me. The only thing I see that might be a problematic and cause you your error is from the example here:

Try modifying your code like this:

const results = await pineconeIndex.upsert({
      upsertRequest: { //added line
         vectors: vectors
     } // added line

Let me know if this worked for you

Ah! I see - the upsert function takes an object with a property upsertRequest. Can’t believe I missed that. Thanks!

1 Like