MemPalace/mempalace · error · EmbeddingAPIError

Embedding API at {self._url} returned no 'data' array: {data

Error message

Embedding API at {self._url} returned no 'data' array: {data.get('error', data)}

What it means

Raised by _vectors_from_response when the response object has no 'data' key or 'data' is not a list. The message prefers data.get('error', data) so that if the server replied with an OpenAI-style error object (e.g. {"error": {"message": ...}}), the actual server error text is surfaced instead of the raw payload skeleton — turning a validation failure into a diagnostic.

Source

Thrown at mempalace/embedding.py:585

        """Validate one ``/v1/embeddings`` response and return L2-normed vectors.

        Guards every way a non-conformant server could corrupt the store
        silently: a missing/short ``data`` array, response ``index`` values
        that aren't the contiguous ``0..n-1`` batch positions (sorting then
        zipping positionally would otherwise misalign vectors with texts), and
        malformed / ragged / base64 embedding payloads. All failures raise
        :class:`EmbeddingAPIError` naming the endpoint rather than a cryptic
        numpy error — a silent wrong result would break the 100%-recall promise.
        """
        import numpy as np

        if not isinstance(data, dict):
            raise EmbeddingAPIError(
                f"Embedding API at {self._url} returned a non-object response: {data}"
            )
        rows = data.get("data")
        if not isinstance(rows, list):
            raise EmbeddingAPIError(
                f"Embedding API at {self._url} returned no 'data' array: {data.get('error', data)}"
            )
        if len(rows) != n:
            raise EmbeddingAPIError(
                f"Embedding API at {self._url} returned {len(rows)} embeddings for {n} inputs"
            )
        # The endpoint may return rows out of order — sort by index, then
        # require the indices to be exactly 0..n-1 so positional alignment is
        # provably correct (a server using absolute or duplicate indices would
        # otherwise pass the count check yet map vectors to the wrong texts).
        try:
            rows = sorted(rows, key=lambda d: d.get("index", -1))
            indices = [r.get("index") for r in rows]
        except AttributeError as e:
            raise EmbeddingAPIError(
                f"Embedding API at {self._url} returned non-object rows: {e}"
            ) from e
        if indices != list(range(n)):

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Read the error field in the message — it usually contains the server's own complaint (bad model name, auth, etc.) and fix that
  2. Verify embedding_api_model matches a model the server actually serves (curl the /v1/models endpoint)
  3. Ensure the embeddings model is loaded in LM Studio / vLLM / Ollama before ingest
  4. Confirm the endpoint path ends in /v1/embeddings, not /v1 or /embeddings-only variants

Example fix

# before
{"embedding_api_model": "text-embedding-3-large"}  # server doesn't host it
# after (local LM Studio example)
{"embedding_api_model": "text-embedding-nomic-embed-text-v1.5"}
Defensive patterns

Strategy: validation

Validate before calling

resp = probe(url, model, inputs=["a"])
assert isinstance(resp, dict) and isinstance(resp.get("data"), list), resp.get("error", resp)

Type guard

def has_data_array(data) -> bool:
    return isinstance(data, dict) and isinstance(data.get("data"), list)

Try / catch

try:
    vecs = ef(texts)
except EmbeddingAPIError as e:
    if "no 'data' array" in str(e):
        # the embedded server error text is in the message; surface it to the user
        show_config_error(e)

Prevention

When it happens

Trigger: The endpoint returned an application-level error in a 200 body: wrong model name ({"error": {"message": "model not found"}}), auth failures from gateways, or a server that returns {"object": "list"} with data under a different key. Also any non-conformant server whose response omits 'data'.

Common situations: embedding_api_model set to a model the server does not host; expired API key on a relay; LM Studio with the embeddings model not loaded; server returns key 'embeddings' instead of 'data'.

Related errors


AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15). Data as JSON: /api/errors/85f6a52c86e90582. Report an issue: GitHub.