{"record":{"id":"5f1cb464fb29e0de","repo":"lancedb/lancedb","slug":"resp-detail","errorCode":null,"errorMessage":"resp[\"detail\"]","messagePattern":"resp\\[\"detail\"\\]","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/python/lancedb/embeddings/jinaai.py","lineNumber":214,"sourceCode":"        self, texts: Union[List[str], np.ndarray], *args, **kwargs\n    ) -> List[np.array]:\n        return self._generate_embeddings(input=texts)\n\n    def _generate_embeddings(self, input: List, *args, **kwargs) -> List[np.array]:\n        \"\"\"\n        Get the embeddings for the given texts\n\n        Parameters\n        ----------\n        texts: list[str] or np.ndarray (of str)\n            The texts to embed\n        \"\"\"\n        self._init_client()\n        resp = JinaEmbeddings._session.post(  # type: ignore\n            API_URL, json={\"input\": input, \"model\": self.name}\n        ).json()\n        if \"data\" not in resp:\n            raise RuntimeError(resp[\"detail\"])\n\n        embeddings = resp[\"data\"]\n\n        # Sort resulting embeddings by index\n        sorted_embeddings = sorted(embeddings, key=lambda e: e[\"index\"])  # type: ignore\n\n        return [result[\"embedding\"] for result in sorted_embeddings]\n\n    def _init_client(self):\n        import requests\n\n        if JinaEmbeddings._session is None:\n            if self.api_key is None and os.environ.get(\"JINA_API_KEY\") is None:\n                api_key_not_found_help(\"jina\")\n            api_key = self.api_key or os.environ.get(\"JINA_API_KEY\")\n            JinaEmbeddings._session = requests.Session()\n            JinaEmbeddings._session.headers.update(\n                {\"Authorization\": f\"Bearer {api_key}\", \"Accept-Encoding\": \"identity\"}","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/lancedb/lancedb/blob/c7b051aff7039333a3f61b79217246c27676806a/python/python/lancedb/embeddings/jinaai.py#L196-L232","documentation":"_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.","triggerScenarios":"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.","commonSituations":"Missing/invalid JINA_API_KEY, wrong model name, a proxy or gateway returning non-Jina JSON, or Jina API error schema changes.","solutions":["Check that the JINA_API_KEY environment variable is set and valid.","Verify the model name passed to the embedding function is correct.","Log the full response body to see the actual error payload; prefer resp.get(\"detail\", resp) when inspecting.","Retry after resolving auth/quota issues; check for proxy/network interference."],"exampleFix":"// before\nif \"data\" not in resp:\n    raise RuntimeError(resp[\"detail\"])\n// after\nif \"data\" not in resp:\n    raise RuntimeError(resp.get(\"detail\", resp))","handlingStrategy":"try-catch","validationCode":"import os\nassert os.environ.get(\"JINA_API_KEY\"), \"JINA_API_KEY not set\"","typeGuard":null,"tryCatchPattern":"try:\n    embeddings = func.compute_source_embeddings(inputs)\nexcept (RuntimeError, KeyError) as e:\n    logger.error(\"Jina API failure: %s\", e)\n    check_api_key_and_quota()\n    raise","preventionTips":["Set and verify JINA_API_KEY before running.","Validate the model name at construction.","Wrap embedding calls with retry/backoff for transient API errors.","Watch for Jina API response schema changes."],"tags":["python","api","network","embeddings"],"backgroundTag":"api-error-response","analyzedSha":"c7b051aff7039333a3f61b79217246c27676806a","analyzedAt":"2026-09-08T23:42:37.579Z","contentChangedAt":"2026-09-08T23:42:37.579Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}