microsoft/semantic-kernel · error · ServiceInvalidResponseError
The response from Amazon Titan model does not contain embedd
Error message
The response from Amazon Titan model does not contain embeddings.
What it means
Raised by the Amazon Titan (Bedrock) text-embedding response parser when the parsed response dict has no 'embedding' key, or that key is not a list. Semantic Kernel expects the Titan embedding endpoint to return a JSON body containing an 'embedding' array of floats; any other shape is treated as an upstream contract violation.
Source
Thrown at python/semantic_kernel/connectors/ai/bedrock/services/model_provider/bedrock_amazon_titan.py:108
def get_text_embedding_request_body(text: str, settings: BedrockEmbeddingPromptExecutionSettings) -> dict[str, Any]:
"""Get the request body for text embedding for Amazon Titan models."""
return remove_none_recursively({
"inputText": text,
# Extension data: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-embed-text.html
"dimensions": settings.extension_data.get("dimensions", None),
"normalize": settings.extension_data.get("normalize", None),
"embeddingTypes": settings.extension_data.get("embeddingTypes", None),
# Extension data: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-embed-mm.html
"embeddingConfig": settings.extension_data.get("embeddingConfig", None),
})
def parse_text_embedding_response(response: dict[str, Any]) -> list[float]:
"""Parse the response from text embedding for Amazon Titan models."""
if "embedding" not in response or not isinstance(response["embedding"], list):
raise ServiceInvalidResponseError("The response from Amazon Titan model does not contain embeddings.")
return response.get("embedding") # type: ignore
# endregion
View on GitHub (pinned to c028a0c7dc)
Solutions
- Verify the model_id is an Amazon Titan embedding model such as amazon.titan-embed-text-v2:0, not a text-generation Titan model.
- Inspect the raw Bedrock response (enable SDK debug logging) to confirm it actually contains an 'embedding' list; if the body is an error, fix the underlying IAM/quota/access issue.
- Upgrade semantic-kernel and boto3 to compatible versions so the Bedrock response schema matches what the parser expects.
- If you configured 'embeddingTypes' extension data, ensure the value is a type Titan returns in the flat 'embedding' field, not a nested batch structure.
Example fix
// before service = BedrockTextEmbeddingService(model_id="amazon.titan-text-premier-v1:0") // after service = BedrockTextEmbeddingService(model_id="amazon.titan-embed-text-v2:0")
Defensive patterns
Strategy: validation
Validate before calling
def is_valid_titan_embedding_response(response: dict) -> bool:
return isinstance(response, dict) and isinstance(response.get("embedding"), list) and len(response["embedding"]) > 0 Type guard
from typing import Any
def is_titan_embedding_response(resp: Any) -> bool:
return isinstance(resp, dict) and isinstance(resp.get("embedding"), list) Try / catch
from semantic_kernel.exceptions.service_exceptions import ServiceInvalidResponseError
try:
embeddings = await service.generate_embeddings([text])
except ServiceInvalidResponseError as e:
if "does not contain embeddings" in str(e):
logger.error("Titan returned no embeddings; raw response needs inspection: %s", e)
raise Prevention
- Always use a Titan embedding model ID (amazon.titan-embed-text-v2:0).
- Enable boto3 debug logging to inspect the raw Bedrock response when first integrating.
- Wrap the embedding call in a ServiceInvalidResponseError catch and surface the raw response for diagnostics.
When it happens
Trigger: Called from BedrockTextEmbeddingService -> parse_text_embedding_response after Amazon Titan embedding invoke. Fires when response.get('embedding') is missing, is None, or is not a list (e.g. the model returned an error object, a different field name like 'vector', or an empty body).
Common situations: Using a Titan model ID that is not an embedding model (e.g. amazon.titan-text-premier) for embeddings; Bedrock returning an access/throttling error payload that shadows the embedding field; mismatch between Bedrock SDK response version and SK parser; model returns 'embeddingTypes' batch format instead of flat 'embedding' list.
Related errors
- The response from Cohere model does not contain embeddings.
- Unsupported service type
- Response is null
- An error occurred while initializing the {nameof(IEmbeddingG
- An error occurred while initializing the {nameof(BedrockText
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/a7d6bfe9c7f4dcf3.
Report an issue: GitHub.