chroma-core/chroma · error · Error

Cohere image embedding supports one image at a time

Error message

Cohere image embedding supports one image at a time

What it means

Pre-flight guard in generate(): the function was constructed in image mode (this.image set, so texts are image URIs/inputs) but received more than one input. Cohere's image embedding endpoint accepts exactly one image per request.

Solutions

  1. Split the batch and call generate() once per image
  2. If the inputs are actually text, construct the function without the image option
  3. Batch text inputs instead (subject to the 96-input limit)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at clients/new-js/packages/ai-embeddings/cohere/src/index.ts:88 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/afe93c8e9358e359. Report an issue: GitHub.

Appendix: source

Thrown at clients/new-js/packages/ai-embeddings/cohere/src/index.ts:88

    if (!apiKey) {
      console.warn(
        `Cohere API key is not set. Please provide it in the constructor or set the environment variable ${apiKeyEnvVar}.`,
      );
    }

    this.client = new CohereClient({ token: apiKey });
    this.apiKeyEnvVar = apiKeyEnvVar;
    this.modelName = modelName;
    this.inputType = inputType;
    this.truncate = truncate;
    this.embeddingType = embeddingType;
    this.image = image;
  }

  public async generate(texts: string[]): Promise<number[][]> {
    if (this.image && texts.length > 1) {
      throw new Error("Cohere image embedding supports one image at a time");
    }

    if (!this.image && texts.length > 96) {
      throw new Error(
        "Cohere image embedding supports a maximum of 96 text inputs at a time",
      );
    }

    const response = await this.client.embed({
      model: this.modelName,
      inputType: this.image ? "image" : this.inputType,
      truncate: this.truncate,
      embeddingTypes: this.embeddingType ? [this.embeddingType] : undefined,
      images: this.image ? texts : undefined,
      texts: !this.image ? texts : undefined,
    });

    const embeddings = response.embeddings;

View on GitHub (pinned to aecdd12c8a)