[Bug]: A new embedding function is not persisted
Author: Mark531Created Dec 11, 2025Updated Sep 24, 2026
Labelsbug
What happened?
Given my OpenAI API key expired, I couldn't use a collection any longer so I recreated one with an embedding function associated with a new API key.
import chromab
from chromadb.utils.embedding_functions import OpenAIEmbeddingFunction
my_client = chromadb.HttpClient(host="localhost", port=5237)
my_col = my_client.get_collection("my_col")
data = my_col.get(include=["embeddings", "metadatas", "documents"])
new_col = my_client.create_collection(
name="my_col2",
embedding_function=OpenAIEmbeddingFunction(model_name="text-embedding-3-small", api_key=OPENAI_API_KEY), # New key!
metadata=my_col.metadata
)
# Copy of the collection data
new_col.add(
ids=data["ids"],
embeddings=data["embeddings"],
metadatas=data["metadatas"],
documents=data["documents"],
)
# This now works!
results = new_col.query(
query_texts=["This is a test"],
n_results=3
)
# Now, I reload the new collection
my_client = chromadb.HttpClient(host="localhost", port=5237)
new_col = my_client.get_collection("my_col2")
# For an unknown reason, this now fails with an error 401 (invalid API key)
results = new_col.query(
query_texts=["This is a test"],
n_results=3
)Versions
Chroma 1.3.5
Relevant log output
Source: chroma-core/chroma