chroma-core/chroma · error · Error

Embedding function ${name} not found

Error message

Embedding function ${name} not found

What it means

getEmbeddingFunction(name) looks up the registry Map that is keyed by each constructor's class name — 'TogetherAIEmbeddingFunction', 'OpenAIEmbeddingFunction', etc. — NOT the instance-level `name` field like 'together_ai'. Any unknown key throws. This is the resolution path used when rehydrating an embedding function from a stored collection config by string.

Source

Thrown at clients/js/packages/chromadb-core/src/embeddings/registry.ts:19

import type { EmbeddingFunctionConstructor } from "./IEmbeddingFunction";
import * as allEmbeddingFunctions from "./all";

const knownEmbeddingFunctions = new Map<string, EmbeddingFunctionConstructor>(
  Object.values(allEmbeddingFunctions).map((fn) => [fn.name, fn]),
);

export const registerEmbeddingFunction = (fn: EmbeddingFunctionConstructor) => {
  if (!fn.name) {
    throw new Error("Embedding function must have a name to be registered.");
  }

  knownEmbeddingFunctions.set(fn.name, fn);
};

export const getEmbeddingFunction = (name: string) => {
  const fn = knownEmbeddingFunctions.get(name);
  if (!fn) {
    throw new Error(`Embedding function ${name} not found`);
  }
  return fn;
};

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Look up by exported class name exactly as in clients/js/packages/chromadb-core/src/embeddings/all.ts (e.g. 'TogetherAIEmbeddingFunction', 'VoyageAIEmbeddingFunction'), not by instance name like 'together_ai'.
  2. Call registerEmbeddingFunction(YourNamedClass) at process startup, before any code that resolves by name.
  3. Keep class names stable across builds (esbuild --keep-names / terser keep_fnames) if names cross process boundaries.
  4. Wrap lookups in try/catch and surface the failing name in logs to catch typos fast.

Example fix

// before
const fn = getEmbeddingFunction("together_ai"); // instance name -> not found

// after
const fn = getEmbeddingFunction("TogetherAIEmbeddingFunction"); // registry key is the class name
Defensive patterns

Strategy: validation

Validate before calling

// Probe before resolving, and fail with the set of valid keys
const KNOWN_EMBEDDING_FUNCTIONS = [
  "TogetherAIEmbeddingFunction",
  "VoyageAIEmbeddingFunction",
  "TransformersEmbeddingFunction",
  /* keep in sync with src/embeddings/all.ts */
];
function resolveEmbeddingFunction(name: string) {
  if (!KNOWN_EMBEDDING_FUNCTIONS.includes(name) && !registeredNames.has(name)) {
    throw new Error(`Unknown embedding function '${name}'. Registered: ${[...registeredNames].join(", ")}`);
  }
  return getEmbeddingFunction(name);
}

Type guard

const isRegisteredEmbeddingName = (name: string): boolean => {
  try {
    getEmbeddingFunction(name);
    return true;
  } catch {
    return false;
  }
};

Try / catch

try {
  const Fn = getEmbeddingFunction(storedName);
} catch (e) {
  const msg = e instanceof Error ? e.message : String(e);
  if (msg.includes("not found")) {
    // Remember: keys are CLASS names, not instance names like 'together_ai'
    throw new Error(`Embedding function '${storedName}' is not registered. Register it with registerEmbeddingFunction(YourNamedClass) at startup.`);
  }
  throw e;
}

Prevention

When it happens

Trigger: getEmbeddingFunction('together_ai') — using the instance name instead of the class name; looking up a custom class before registerEmbeddingFunction() ran; typo or case mismatch in the class-name string; bundle A registers a class whose name a minifier changed while bundle B looks up the original name.

Common situations: Persisting embedding function names to a database/config and restoring them later; multi-process apps where registration happens in one process and lookup in another; minified builds renaming classes inconsistently.

Related errors


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