{"record":{"id":"a7d6bfe9c7f4dcf3","repo":"microsoft/semantic-kernel","slug":"the-response-from-amazon-titan-model-does-not-cont","errorCode":null,"errorMessage":"The response from Amazon Titan model does not contain embeddings.","messagePattern":"The response from Amazon Titan model does not contain embeddings\\.","errorType":"exception","errorClass":"ServiceInvalidResponseError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/bedrock/services/model_provider/bedrock_amazon_titan.py","lineNumber":108,"sourceCode":"\n\ndef get_text_embedding_request_body(text: str, settings: BedrockEmbeddingPromptExecutionSettings) -> dict[str, Any]:\n    \"\"\"Get the request body for text embedding for Amazon Titan models.\"\"\"\n    return remove_none_recursively({\n        \"inputText\": text,\n        # Extension data: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-embed-text.html\n        \"dimensions\": settings.extension_data.get(\"dimensions\", None),\n        \"normalize\": settings.extension_data.get(\"normalize\", None),\n        \"embeddingTypes\": settings.extension_data.get(\"embeddingTypes\", None),\n        # Extension data: https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-embed-mm.html\n        \"embeddingConfig\": settings.extension_data.get(\"embeddingConfig\", None),\n    })\n\n\ndef parse_text_embedding_response(response: dict[str, Any]) -> list[float]:\n    \"\"\"Parse the response from text embedding for Amazon Titan models.\"\"\"\n    if \"embedding\" not in response or not isinstance(response[\"embedding\"], list):\n        raise ServiceInvalidResponseError(\"The response from Amazon Titan model does not contain embeddings.\")\n\n    return response.get(\"embedding\")  # type: ignore\n\n\n# endregion\n","sourceCodeStart":90,"sourceCodeEnd":114,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/bedrock/services/model_provider/bedrock_amazon_titan.py#L90-L114","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nservice = BedrockTextEmbeddingService(model_id=\"amazon.titan-text-premier-v1:0\")\n// after\nservice = BedrockTextEmbeddingService(model_id=\"amazon.titan-embed-text-v2:0\")","handlingStrategy":"validation","validationCode":"def is_valid_titan_embedding_response(response: dict) -> bool:\n    return isinstance(response, dict) and isinstance(response.get(\"embedding\"), list) and len(response[\"embedding\"]) > 0","typeGuard":"from typing import Any\n\ndef is_titan_embedding_response(resp: Any) -> bool:\n    return isinstance(resp, dict) and isinstance(resp.get(\"embedding\"), list)","tryCatchPattern":"from semantic_kernel.exceptions.service_exceptions import ServiceInvalidResponseError\n\ntry:\n    embeddings = await service.generate_embeddings([text])\nexcept ServiceInvalidResponseError as e:\n    if \"does not contain embeddings\" in str(e):\n        logger.error(\"Titan returned no embeddings; raw response needs inspection: %s\", e)\n    raise","preventionTips":["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."],"tags":["bedrock","embeddings","amazon-titan","response-parsing"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}