PineconeClient: Error calling upsert:

Getting the following error while upserting-

[PineconeError: PineconeClient: Error calling upsert: PineconeError: PineconeClient: Error calling upsertRaw: RequiredError: Required parameter requestParameters.upsertRequest was null or undefined when calling upsert.]

Here is the code -

import { PineconeClient } from "@pinecone-database/pinecone";
const pinecone = new PineconeClient();
await pinecone.init({
  environment: "<env>",
  apiKey: "<api_key>",
});

const pineconeIndex = pinecone.Index("<index_name>");

let vectors = data.map( async (item,i) => {

    let openai_embedding = await createEmbedding(item.subtitle_text);

  //console.log(item.subtitle_embedding.length)

    return {
      id: item.video_id,
      metadata:{
        subtitle: item.subtitle_text
        },
       values: openai_embedding
    }
  });

  vectors = await Promise.all(vectors);
  //console.log(vectors)

  let insertBatches = [];
  while(vectors.length) {

    let batchedVectors = vectors.splice(0, 250);

    //console.log(batchedVectors)

    let pineconeResult = await pineconeIndex.upsert({
      namespace: "example-namespace",
      vectors: batchedVectors
    });

    insertBatches.push(pineconeResult);
   }

I have checked already-

  1. API key and environment is correct.
  2. Tried with creating new account.
  3. checked the openai vectors dimensions is same as pinecone index dimensions.

There is lots of similar posts are available but none of them solved my query.

Thanks a lot.

Hi,

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: https://docs.pinecone.io/docs/node-client#indexupsert

Try modifying your code like this:

let pineconeResult = await pineconeIndex.upsert({
      upsertRequest: { //added line
        namespace: "example-namespace",
        vectors: batchedVectors
     } // added line
});

Hope this helps

@Jasper thanks a lot…

I was missing “upsertRequest:”

1 Like

maybe me missing a point - getting similar error after 99 vectors are upserted. It won’t go to a 100th one. Even if I add pause in between. I am new to node.js and Pinecone - thanks