chroma-core/chroma · error · Error

Failed to generate Gemini embeddings

Error message

Failed to generate Gemini embeddings

What it means

Response-shape validation in generate(): the Gemini SDK returned successfully but the result lacked `embeddings` or some entry had undefined `values`. Indicates the API returned an empty/partial result despite a 200 response, or the response shape changed.

Solutions

  1. Log the raw result to see which entries are missing values
  2. Check for empty input strings or unsupported content in the texts array
  3. Retry; if persistent, verify the model name supports embedContent
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at clients/new-js/packages/ai-embeddings/google-gemini/src/index.ts:91 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/1fc7da30a671f934. Report an issue: GitHub.

Appendix: source

Thrown at clients/new-js/packages/ai-embeddings/google-gemini/src/index.ts:91

        model: this.modelName,
        contents: texts,
        config:
          this.taskType || this.dimension
            ? {
                ...(this.taskType && { taskType: this.taskType }),
                ...(this.dimension && { outputDimensionality: this.dimension }),
              }
            : undefined,
      });
    } catch (e) {
      throw new Error(`Failed to generate Gemini embeddings: ${e}`);
    }

    if (
      !result.embeddings ||
      !result.embeddings.every((e) => e.values !== undefined)
    ) {
      throw new Error("Failed to generate Gemini embeddings");
    }

    return result.embeddings.map((e) => e.values as number[]);
  }

  public static buildFromConfig(
    config: GoogleGeminiConfig,
  ): GoogleGeminiEmbeddingFunction {
    return new GoogleGeminiEmbeddingFunction({
      modelName: config.model_name,
      apiKeyEnvVar: config.api_key_env_var,
      taskType: config.task_type,
      dimension: config.dimension,
    });
  }

  public defaultSpace(): EmbeddingFunctionSpace {
    return "cosine";

View on GitHub (pinned to aecdd12c8a)