{"record":{"id":"593824907b93ff67","repo":"BerriAI/litellm","slug":"unexpected-mistral-completion-response","errorCode":null,"errorMessage":"Unexpected mistral completion response","messagePattern":"Unexpected mistral completion response","errorType":"http","errorClass":"BedrockError","httpStatus":400,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_transformations/amazon_mistral_transformation.py","lineNumber":109,"sourceCode":"        \"\"\"This function extracts the output text from a bedrock mistral completion.\n        As a side effect, it updates the finish reason for a model response.\n\n        Args:\n            completion_response: JSON from the completion.\n            model_response: ModelResponse\n\n        Returns:\n            A string with the response of the LLM\n\n        \"\"\"\n        if \"choices\" in completion_response:\n            outputText = completion_response[\"choices\"][0][\"message\"][\"content\"]\n            model_response.choices[0].finish_reason = completion_response[\"choices\"][0][\"finish_reason\"]\n        elif \"outputs\" in completion_response:\n            outputText = completion_response[\"outputs\"][0][\"text\"]\n            model_response.choices[0].finish_reason = completion_response[\"outputs\"][0][\"stop_reason\"]\n        else:\n            raise BedrockError(message=\"Unexpected mistral completion response\", status_code=400)\n\n        return outputText\n","sourceCodeStart":91,"sourceCodeEnd":112,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/chat/invoke_transformations/amazon_mistral_transformation.py#L91-L112","documentation":"Raised by AmazonMistralConfig.get_outputText when the Bedrock Mistral completion response contains neither a 'choices' key (OpenAI-style Mistral responses) nor an 'outputs' key (native Mistral invoke format). It is a BedrockError 400 indicating the response schema is not one of the two shapes litellm can map to output text.","triggerScenarios":"Calling a bedrock/mistral.* model via the invoke route when Bedrock returns an error-shaped body that still parses as JSON, or a new/deprecated Mistral model whose response format differs (e.g. mistral-large-2 variants), leaving the parser without a recognized text field.","commonSituations":"Model deprecated by AWS and returning a terse error payload, wrong model ID mapping to the Mistral parser, or litellm versions predating a new Mistral model release.","solutions":["Log the raw completion_response payload (set LITELLM_LOG=DEBUG) to see the actual schema returned.","Switch to bedrock/converse/mistral.* - the Converse API response format is stable and avoids the legacy parser.","Upgrade litellm if the model is new; support for new Mistral variants lands in the transformation config.","Confirm the model ID exists in your region and is enabled (a disabled model can return an error body)."],"exampleFix":"# before\nresp = litellm.completion(model=\"bedrock/mistral.mistral-7b-instruct-v0:2\", messages=msgs)\n\n# after\nresp = litellm.completion(model=\"bedrock/converse/mistral.mistral-7b-instruct-v0:2\", messages=msgs)","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.exceptions import BedrockError\ntry:\n    resp = litellm.completion(model=\"bedrock/mistral.<model>\", messages=msgs)\nexcept BedrockError as e:\n    if e.status_code == 400 and \"Unexpected mistral\" in str(e):\n        resp = litellm.completion(model=\"bedrock/converse/mistral.<model>\", messages=msgs)\n    else:\n        raise","preventionTips":["Default new Bedrock models to the bedrock/converse/<model> prefix.","Wrap deprecated-model calls with a converse fallback.","Keep a mapping of verified model IDs per region and validate model strings before calls."],"tags":["aws","bedrock","mistral","response-parsing","converse"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}