lancedb/lancedb · error · RuntimeError

resp["detail"]

Error message

resp["detail"]

What it means

_generate_embeddings posts to the Jina API; if the response JSON lacks a 'data' key, it assumes an error payload and raises RuntimeError(resp['detail']). A KeyError('detail') additionally occurs when the error body itself has no 'detail' field.

Solutions

  1. Check that the JINA_API_KEY environment variable is set and valid.
  2. Verify the model name passed to the embedding function is correct.
  3. Log the full response body to see the actual error payload; prefer resp.get("detail", resp) when inspecting.
  4. Retry after resolving auth/quota issues; check for proxy/network interference.

Example fix

// before
if "data" not in resp:
    raise RuntimeError(resp["detail"])
// after
if "data" not in resp:
    raise RuntimeError(resp.get("detail", resp))
Defensive patterns

Strategy: try-catch

Validate before calling

import os
assert os.environ.get("JINA_API_KEY"), "JINA_API_KEY not set"

Try / catch

try:
    embeddings = func.compute_source_embeddings(inputs)
except (RuntimeError, KeyError) as e:
    logger.error("Jina API failure: %s", e)
    check_api_key_and_quota()
    raise

Prevention

When it happens

Trigger: The Jina API returns an error JSON (invalid API key, bad model name, rate limit, malformed input) without a 'data' key; the code then accesses resp['detail'], which raises KeyError if the error body uses a different shape.

Common situations: Missing/invalid JINA_API_KEY, wrong model name, a proxy or gateway returning non-Jina JSON, or Jina API error schema changes.

Related errors


AI-assisted analysis of lancedb/lancedb@c7b051aff7 (2026-09-08). Data as JSON: /api/errors/5f1cb464fb29e0de. Report an issue: GitHub.

Appendix: source

Thrown at python/python/lancedb/embeddings/jinaai.py:214

        self, texts: Union[List[str], np.ndarray], *args, **kwargs
    ) -> List[np.array]:
        return self._generate_embeddings(input=texts)

    def _generate_embeddings(self, input: List, *args, **kwargs) -> List[np.array]:
        """
        Get the embeddings for the given texts

        Parameters
        ----------
        texts: list[str] or np.ndarray (of str)
            The texts to embed
        """
        self._init_client()
        resp = JinaEmbeddings._session.post(  # type: ignore
            API_URL, json={"input": input, "model": self.name}
        ).json()
        if "data" not in resp:
            raise RuntimeError(resp["detail"])

        embeddings = resp["data"]

        # Sort resulting embeddings by index
        sorted_embeddings = sorted(embeddings, key=lambda e: e["index"])  # type: ignore

        return [result["embedding"] for result in sorted_embeddings]

    def _init_client(self):
        import requests

        if JinaEmbeddings._session is None:
            if self.api_key is None and os.environ.get("JINA_API_KEY") is None:
                api_key_not_found_help("jina")
            api_key = self.api_key or os.environ.get("JINA_API_KEY")
            JinaEmbeddings._session = requests.Session()
            JinaEmbeddings._session.headers.update(
                {"Authorization": f"Bearer {api_key}", "Accept-Encoding": "identity"}

View on GitHub (pinned to c7b051aff7)