I'm testing my first embed from firebase but the text content throws an error

Hi all! Completely new to this and chugging through a test fixing errors along the way, but stumped by this one.

I’m testing a Firebase cloud function to backfill embeds on one of my tables (so I can see how to use genai on my own data).

It pulls the data fine and iterates through all of the documents, but it doesn’t like something about the ‘content:’ part of the embedContents call and I have no idea what. :frowning:

Now, you can see some of the data below, and maybe this won’t actually do anything useful from the perspective of interfacing with the database, but at this point I want to understand what’s wrong so I can test and see. Thanks in advance for any help!

Update: I guess the question is really, what is wrong with this text string that embedContent doesn’t recognize it as a valid ‘content:’?

“0 1 59 Strength Mental Conditioning Firebreathing Finisher Squat 0 0 50 Weight Reps Distance Time Calories Movement Scaled Rx Competition Strongman 0 0 Quads Hamstrings Glutes 0 0 Yoke Core 0 Weight plates bumper plates 0 Yoke 0 0 Squat”

Code:
const MODEL_NAME = “gemini-embedding-001”;
const genAI = new GoogleGenerativeAI(GEM_API_KEY);
.
. <setting up firebase connection, pulling data, etc>
.
const textToEmbed = extractTextFromDocument(docData);

  if (!textToEmbed) {
    console.log(`No text found in document ${docId} to generate an embedding. Skipping.`);
    continue; // Move to the next document
  }

  try {
    // Generate the embedding
    const result = await model.embedContent({
      content: textToEmbed,
    } );

    // previous:  const result = await model.embedContent({parts: [{text: textToEmbed}]});
    // ex:    contents: [{role: "user", parts: [{text: prompt}]}],
    const embedding = result.embedding.values;

Here’s the error (note that some of this has been removed because I needed to break the links as a new poster limited to 2 links):

DEFAULT 2025-06-25T19:27:47.983265Z [resource.labels.functionName: backfillExerciseEmbeddings] [labels.executionId: hgyhc63tfpnm] Error generating embedding for document Yoke: GoogleGenerativeAIFetchError: [GoogleGenerativeAI Error]: Error fetching from /v1beta/models/gemini-embedding-001:embedContent: [400 Bad Request] Invalid value at ‘content’ (oogle.ai.generativelanguage.v1beta.Content), “0 1 59 Strength Mental Conditioning Firebreathing Finisher Squat 0 0 50 Weight Reps Distance Time Calories Movement Scaled Rx Competition Strongman 0 0 Quads Hamstrings Glutes 0 0 Yoke Core 0 Weight plates bumper plates 0 Yoke 0 0 Squat” [{“/google.rpc.BadRequest”,“fieldViolations”:[{“d”:“content”,“description”:“Invalid value at ‘content’ (com/google.ai.generativelanguage.v1beta.Content), "0 1 59 Strength Mental Conditioning Firebreathing Finisher Squat 0 0 50 Weight Reps Distance Time Calories Movement Scaled Rx Competition Strongman 0 0 Quads Hamstrings Glutes 0 0 Yoke Core 0 Weight plates bumper plates 0 Yoke 0 0 Squat"”}]}]
{
“textPayload”: “Error generating embedding for document Yoke: GoogleGenerativeAIFetchError: [GoogleGenerativeAI Error]: Error fetching from /v1beta/models/gemini-embedding-001:embedContent: [400 Bad Request] Invalid value at ‘content’ (.googleapis.com/google.ai.generativelanguage.v1beta.Content), "0 1 59 Strength Mental Conditioning Firebreathing Finisher Squat 0 0 50 Weight Reps Distance Time Calories Movement Scaled Rx Competition Strongman 0 0 Quads Hamstrings Glutes 0 0 Yoke Core 0 Weight plates bumper plates 0 Yoke 0 0 Squat" [{"@pe":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"content","description":"Invalid value at ‘content’ (com/google.ai.generativelanguage.v1beta.Content), \"0 1 59 Strength Mental Conditioning Firebreathing Finisher Squat 0 0 50 Weight Reps Distance Time Calories Movement Scaled Rx Competition Strongman 0 0 Quads Hamstrings Glutes 0 0 Yoke Core 0 Weight plates bumper plates 0 Yoke 0 0 Squat\""}]}]”,