chroma-core/chroma · error · ValueError
No embeddings returned from the API
Error message
No embeddings returned from the API
What it means
After a successful embed_content call, GoogleGeminiEmbeddingFunction validates the response shape: response must have a non-empty 'embeddings' attribute. An HTTP-200 response with no embeddings violates the API contract, so the function refuses to return an empty/partial result. This is almost always SDK-version drift or a backend anomaly rather than a user-input problem.
Source
Thrown at chromadb/utils/embedding_functions/google_embedding_function.py:114
from google.genai.types import EmbedContentConfig
config = EmbedContentConfig(
task_type=self.task_type,
output_dimensionality=self.dimension,
)
try:
response = self.client.models.embed_content(
model=self.model_name,
contents=input,
config=config,
)
except Exception as e:
raise ValueError(f"Failed to generate embeddings: {str(e)}") from e
# Validate response structure
if not hasattr(response, "embeddings") or not response.embeddings:
raise ValueError("No embeddings returned from the API")
embeddings_list = []
for ce in response.embeddings:
if not hasattr(ce, "values"):
raise ValueError("Malformed embedding response: missing 'values'")
embeddings_list.append(np.array(ce.values, dtype=np.float32))
return cast(Embeddings, embeddings_list)
@staticmethod
def name() -> str:
return "google_gemini"
def default_space(self) -> Space:
return "cosine"
def supported_spaces(self) -> List[Space]:
return ["cosine", "l2", "ip"]View on GitHub (pinned to aecdd12c8a)
Solutions
- Pin google-genai to a version known to work with your chromadb release (check chromadb's optional-dependency pins)
- If it occurs in tests, make the mock return an object with embeddings=[...] where each item has .values
- Retry once - transient backend anomalies can clear
- Report with the raw response if it persists across pinned versions
Defensive patterns
Strategy: try-catch
Try / catch
try:
vecs = ef(docs)
except ValueError as e:
if "No embeddings returned" in str(e):
# response-shape anomaly (SDK drift/backend glitch): capture context, retry once
vecs = ef(docs)
else:
raise Prevention
- Pin google-genai to the version range tested with your chromadb release
- Make test mocks return objects with non-empty embeddings=[...] entries
- Log model_name and google-genai version alongside the failure for diagnosability
When it happens
Trigger: A google-genai version whose response object lacks or empties the 'embeddings' field; a Gemini backend anomaly returning an empty embedding list; a mocked/stubbed client in tests that returns an object without .embeddings.
Common situations: Upgrading google-genai to a release with changed response types; test doubles that mimic the client incompletely; rare upstream incidents.
Related errors
- Malformed embedding response: missing 'values'
- The google-genai python package is not installed. Please ins
- The {self.api_key_env_var} environment variable must be set
- Failed to generate embeddings: {str(e)}
- Unknown error
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/10f8b0d8abc2acd8.
Report an issue: GitHub.