{"record":{"id":"294253ee761cb0d6","repo":"BerriAI/litellm","slug":"no-embedding-data-found-in-response-response","errorCode":null,"errorMessage":"No embedding data found in response: {response}","messagePattern":"No embedding data found in response: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/embed/amazon_titan_v2_transformation.py","lineNumber":101,"sourceCode":"        for index, response in enumerate(response_list):\n            _parsed_response = AmazonTitanV2EmbeddingResponse(**response)\n\n            # According to AWS docs, embeddingsByType is always present\n            # If binary was requested (encoding_format=\"base64\"), use binary data\n            # Otherwise, use float data from embeddingsByType or fallback to embedding field\n            embedding_data: list[float] | list[int]\n\n            if \"embeddingsByType\" in _parsed_response and \"binary\" in _parsed_response[\"embeddingsByType\"]:\n                # Use binary data if available (for encoding_format=\"base64\")\n                embedding_data = _parsed_response[\"embeddingsByType\"][\"binary\"]\n            elif \"embeddingsByType\" in _parsed_response and \"float\" in _parsed_response[\"embeddingsByType\"]:\n                # Use float data from embeddingsByType\n                embedding_data = _parsed_response[\"embeddingsByType\"][\"float\"]\n            elif \"embedding\" in _parsed_response:\n                # Fallback to legacy embedding field\n                embedding_data = _parsed_response[\"embedding\"]\n            else:\n                raise ValueError(f\"No embedding data found in response: {response}\")\n\n            transformed_responses.append(\n                Embedding(\n                    embedding=embedding_data,\n                    index=index,\n                    object=\"embedding\",\n                )\n            )\n            total_prompt_tokens += _parsed_response[\"inputTextTokenCount\"]\n\n        usage: Final = Usage(\n            prompt_tokens=total_prompt_tokens,\n            completion_tokens=0,\n            total_tokens=total_prompt_tokens,\n        )\n        return EmbeddingResponse(model=model, usage=usage, data=transformed_responses)\n","sourceCodeStart":83,"sourceCodeEnd":118,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/embed/amazon_titan_v2_transformation.py#L83-L118","documentation":"Raised by AmazonTitanV2Config._transform_response when a parsed Titan v2 embedding response contains none of the expected fields: embeddingsByType.binary, embeddingsByType.float, or the legacy top-level 'embedding'. This means the HTTP call nominally succeeded but the body is not a Titan v2 embedding result — most often an AWS error/empty payload that wasn't surfaced as a status error, or a schema change.","triggerScenarios":"AWS returns 200 with an error-shaped or empty JSON body; calling amazon.titan-embed-text-v2:0 for an unsupported input (e.g. empty inputText after upstream stripping) so AWS returns a body without vectors; a proxied/mangled response that dropped the embedding fields; response-shape drift after an AWS update.","commonSituations":"Sending inputs that reduce to empty strings (empty list of strings, whitespace-only); dimension/normalize parameters combos AWS rejects with a 200-wrapped error; older litellm versions against updated Titan endpoints; corporate proxies rewriting bodies.","solutions":["Log the full response dict (the error message embeds it) to see what AWS actually returned","Guard inputs: strip and reject empty strings before calling embedding()","Upgrade litellm — Titan v2 response handling has been revised across versions","Reproduce with the AWS CLI to check whether the same input returns vectors natively"],"exampleFix":"# before\nresp = litellm.embedding(model='bedrock/amazon.titan-embed-text-v2:0', input=[''])\n\n# after\ninputs = [t for t in texts if t and t.strip()]\nif not inputs:\n    raise ValueError('no non-empty texts to embed')\nresp = litellm.embedding(model='bedrock/amazon.titan-embed-text-v2:0', input=inputs)","handlingStrategy":"try-catch","validationCode":"def assert_nonempty_inputs(inputs: list[str]) -> None:\n    cleaned = [i for i in inputs if isinstance(i, str) and i.strip()]\n    if not cleaned:\n        raise ValueError('no non-empty inputs to embed')\n    if len(cleaned) != len(inputs):\n        import warnings\n        warnings.warn(f'{len(inputs) - len(cleaned)} empty input(s) dropped before embedding')","typeGuard":"from typing import Any\n\ndef looks_like_titan_v2_response(resp: dict[str, Any]) -> bool:\n    ebt = resp.get('embeddingsByType')\n    return isinstance(ebt, dict) and any(k in ebt for k in ('binary', 'float')) or 'embedding' in resp","tryCatchPattern":"try:\n    resp = litellm.embedding(model='bedrock/amazon.titan-embed-text-v2:0', input=inputs)\nexcept ValueError as e:\n    if 'No embedding data found in response' in str(e):\n        logging.error('titan returned non-vector body; inputs=%r', inputs[:3])\n        raise TransientEmbeddingError('retry with cleaned inputs') from e\n    raise","preventionTips":["Strip and drop empty/whitespace inputs before calling embedding()","Pin your litellm version and regression-test Titan embeddings after upgrades","Log raw response bodies at DEBUG in staging to catch schema drift early"],"tags":["bedrock","titan","embedding","response-parsing","unexpected-response"],"backgroundTag":"missing-response-field","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}