Batch Embeddings Javascript code

Hi, I’m trying to use the batch create embeddings API as per the documentation but above the code snippet it first says “use the batches.create_embeddings API…” and then in the JS snippet it uses “client.batches.createEmbeddings” - however when I try either createEmbeddings and create_embeddings I get an error: “TypeError: Cannot read properties of undefined (reading ‘createEmbeddings’)”

Here’s the entire relevant code snippet:


const genAI = new GoogleGenerativeAI(‘API_KEY_HIDDEN’);
let batchJob;
batchJob = await genAI.batches.createEmbeddings({
model: ‘gemini-embedding-001’,
// For a predefined a list of requests inlinedRequests
src: {inlinedRequests: inlinedRequests},
config: {displayName: ‘Inlined embeddings batch’},
});
console.log(Created batch job: ${batchJob.name});

Hi @Tomislav ,

I faced the same issue in the older genai-js SDK, but with the latest version(1.28.0), I am now able to create embeddings using the batch APIs. Could you please try the latest genai-js and let me know if your issue is resolved?

Thank you!!