BerriAI/litellm · error · ValueError
No embedding data found in response
Error message
No embedding data found in response: {response} What it means
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.
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
Example fix
# before
resp = litellm.embedding(model='bedrock/amazon.titan-embed-text-v2:0', input=[''])
# after
inputs = [t for t in texts if t and t.strip()]
if not inputs:
raise ValueError('no non-empty texts to embed')
resp = litellm.embedding(model='bedrock/amazon.titan-embed-text-v2:0', input=inputs) Defensive patterns
Strategy: try-catch
Validate before calling
def assert_nonempty_inputs(inputs: list[str]) -> None:
cleaned = [i for i in inputs if isinstance(i, str) and i.strip()]
if not cleaned:
raise ValueError('no non-empty inputs to embed')
if len(cleaned) != len(inputs):
import warnings
warnings.warn(f'{len(inputs) - len(cleaned)} empty input(s) dropped before embedding') Type guard
from typing import Any
def looks_like_titan_v2_response(resp: dict[str, Any]) -> bool:
ebt = resp.get('embeddingsByType')
return isinstance(ebt, dict) and any(k in ebt for k in ('binary', 'float')) or 'embedding' in resp Try / catch
try:
resp = litellm.embedding(model='bedrock/amazon.titan-embed-text-v2:0', input=inputs)
except ValueError as e:
if 'No embedding data found in response' in str(e):
logging.error('titan returned non-vector body; inputs=%r', inputs[:3])
raise TransientEmbeddingError('retry with cleaned inputs') from e
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- AgentCore: Failed to read/parse JSON response body
- Error in response object format, got None
- Error in response object format, got None
- Error processing response
- Error processing response
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/294253ee761cb0d6.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/llms/bedrock/embed/amazon_titan_v2_transformation.py:101
for index, response in enumerate(response_list):
_parsed_response = AmazonTitanV2EmbeddingResponse(**response)
# According to AWS docs, embeddingsByType is always present
# If binary was requested (encoding_format="base64"), use binary data
# Otherwise, use float data from embeddingsByType or fallback to embedding field
embedding_data: list[float] | list[int]
if "embeddingsByType" in _parsed_response and "binary" in _parsed_response["embeddingsByType"]:
# Use binary data if available (for encoding_format="base64")
embedding_data = _parsed_response["embeddingsByType"]["binary"]
elif "embeddingsByType" in _parsed_response and "float" in _parsed_response["embeddingsByType"]:
# Use float data from embeddingsByType
embedding_data = _parsed_response["embeddingsByType"]["float"]
elif "embedding" in _parsed_response:
# Fallback to legacy embedding field
embedding_data = _parsed_response["embedding"]
else:
raise ValueError(f"No embedding data found in response: {response}")
transformed_responses.append(
Embedding(
embedding=embedding_data,
index=index,
object="embedding",
)
)
total_prompt_tokens += _parsed_response["inputTextTokenCount"]
usage: Final = Usage(
prompt_tokens=total_prompt_tokens,
completion_tokens=0,
total_tokens=total_prompt_tokens,
)
return EmbeddingResponse(model=model, usage=usage, data=transformed_responses)
View on GitHub (pinned to 77b7c6c40c)