{"record":{"id":"48eb34152b26272e","repo":"BerriAI/litellm","slug":"embedding-response-is-not-an-instance-of-embedding","errorCode":null,"errorMessage":"embedding_response is not an instance of EmbeddingResponse","messagePattern":"embedding_response is not an instance of EmbeddingResponse","errorType":"exception","errorClass":"AzureOpenAIError","httpStatus":500,"severity":"error","filePath":"litellm/llms/azure/azure.py","lineNumber":724,"sourceCode":"                )\n            stringified_response: Final = response.model_dump()\n\n            ## LOGGING\n            logging_obj.post_call(\n                input=input,\n                api_key=api_key,\n                additional_args={\"complete_input_dict\": data},\n                original_response=stringified_response,\n            )\n            embedding_response: Final = convert_to_model_response_object(\n                response_object=stringified_response,\n                model_response_object=model_response,\n                hidden_params={\"headers\": headers},\n                _response_headers=process_azure_headers(headers),\n                response_type=\"embedding\",\n            )\n            if not isinstance(embedding_response, EmbeddingResponse):\n                raise AzureOpenAIError(\n                    status_code=500,\n                    message=\"embedding_response is not an instance of EmbeddingResponse\",\n                )\n            return embedding_response\n        except Exception as e:\n            ## LOGGING\n            logging_obj.post_call(\n                input=input,\n                api_key=api_key,\n                additional_args={\"complete_input_dict\": data},\n                original_response=str(e),\n            )\n            raise e\n\n    def embedding(\n        self,\n        model: str,\n        input: list,","sourceCodeStart":706,"sourceCodeEnd":742,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure/azure.py#L706-L742","documentation":"After converting the Azure embedding response with `convert_to_model_response_object`, the result must be an instance of EmbeddingResponse; otherwise this 500 is raised. It is an internal consistency check — conversion normally either succeeds or throws its own error, so seeing this means the converter returned an unexpected type (custom response object injection, version skew).","triggerScenarios":"Passing a custom `model_response` object of the wrong class into the embedding call; a litellm version where internal response types changed under a partially-upgraded install.","commonSituations":"Mixed-version installs after upgrading litellm in place; code that reuses or subclasses response objects incorrectly.","solutions":["Do not pass a custom model_response argument; let LiteLLM create it.","Reinstall cleanly: pip install --force-reinstall litellm to eliminate mixed-version internals.","Verify you are not monkeypatching convert_to_model_response_object in tests."],"exampleFix":"# before\nresp = litellm.embedding(model='azure/text-embedding-3-large', input=['hi'], model_response=my_custom_obj)\n\n# after\nresp = litellm.embedding(model='azure/text-embedding-3-large', input=['hi'])","handlingStrategy":"validation","validationCode":"# Don't pass a custom model_response; if you must, ensure it's the right type:\nfrom litellm.types.utils import EmbeddingResponse\nassert my_response_obj is None or isinstance(my_response_obj, EmbeddingResponse)","typeGuard":"from litellm.types.utils import EmbeddingResponse\n\ndef is_embedding_response(r) -> bool:\n    return isinstance(r, EmbeddingResponse)","tryCatchPattern":null,"preventionTips":["Never reuse or subclass response objects across calls.","Do clean reinstalls of litellm to avoid mixed internal versions."],"tags":["azure","embeddings","internal-invariant","version-mismatch"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}