{"record":{"id":"c8325d2558762e8d","repo":"microsoft/semantic-kernel","slug":"the-response-from-cohere-model-does-not-contain-em","errorCode":null,"errorMessage":"The response from Cohere model does not contain embeddings.","messagePattern":"The response from Cohere model does not contain embeddings\\.","errorType":"exception","errorClass":"ServiceInvalidResponseError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/bedrock/services/model_provider/bedrock_cohere.py","lineNumber":96,"sourceCode":"# endregion\n\n# region Text Embedding\n\n\ndef get_text_embedding_request_body(text: str, settings: BedrockEmbeddingPromptExecutionSettings) -> Any:\n    \"\"\"Get the request body for text embedding for Cohere Command models.\"\"\"\n    return remove_none_recursively({\n        \"texts\": [text],\n        \"input_type\": settings.extension_data.get(\"input_type\", \"search_document\"),\n        \"truncate\": settings.extension_data.get(\"truncate\", None),\n        \"embedding_types\": settings.extension_data.get(\"embedding_types\", None),\n    })\n\n\ndef parse_text_embedding_response(response: dict[str, Any]) -> list[float]:\n    \"\"\"Parse the response from text embedding for Cohere Command models.\"\"\"\n    if \"embeddings\" not in response or not isinstance(response[\"embeddings\"], list) or len(response[\"embeddings\"]) == 0:\n        raise ServiceInvalidResponseError(\"The response from Cohere model does not contain embeddings.\")\n\n    return response.get(\"embeddings\")[0]  # type: ignore\n\n\n# endregion\n","sourceCodeStart":78,"sourceCodeEnd":102,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/bedrock/services/model_provider/bedrock_cohere.py#L78-L102","documentation":"Raised by the Cohere (Bedrock) text-embedding response parser when the response dict has no 'embeddings' key, that key is not a list, or the list is empty. The parser then dereferences response['embeddings'][0], so it defends all three conditions up front.","triggerScenarios":"Called from BedrockTextEmbeddingService -> parse_text_embedding_response for a Cohere embedding model (e.g. cohere.embed-english-v3). Fires when the Cohere payload omits 'embeddings', returns it as a non-list, or returns an empty list (Cohere rejected the input text, or returned an error/status object instead).","commonSituations":"Using a Cohere chat model ID instead of a Cohere embedding model ID; Cohere rejecting input because input_type extension data is invalid; Bedrock throttling returning an error body; the 'texts' array in the request was empty after remove_none_recursively; version skew between Cohere embedding response schema and the parser.","solutions":["Confirm the model_id is a Cohere embedding model such as cohere.embed-english-v3 or cohere.embed-multilingual-v3, not a Command chat model.","Check the raw response body; if Cohere returns a validation error (e.g. invalid input_type/truncate), fix the extension_data settings accordingly.","Ensure the text passed to embed is non-empty so remove_none_recursively does not strip the 'texts' field.","Upgrade semantic-kernel and boto3 so the Cohere response schema the parser reads matches what Bedrock returns."],"exampleFix":"// before\nsettings.extension_data[\"input_type\"] = \"\"\n// after\nsettings.extension_data[\"input_type\"] = \"search_document\"","handlingStrategy":"validation","validationCode":"def is_valid_cohere_embedding_response(response: dict) -> bool:\n    return (\n        isinstance(response, dict)\n        and isinstance(response.get(\"embeddings\"), list)\n        and len(response[\"embeddings\"]) > 0\n    )","typeGuard":"from typing import Any\n\ndef is_cohere_embedding_response(resp: Any) -> bool:\n    return isinstance(resp, dict) and isinstance(resp.get(\"embeddings\"), list) and bool(resp[\"embeddings\"])","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(\"Cohere embedding call failed; check input_type/truncate extension data\")\n    raise","preventionTips":["Use a Cohere embedding model ID (cohere.embed-english-v3).","Set extension_data input_type to a valid Cohere value (search_document/search_query/classification).","Inspect the raw response when first integrating to confirm the 'embeddings' field shape."],"tags":["bedrock","embeddings","cohere","response-parsing"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}