BerriAI/litellm · error · BedrockError

Unexpected mistral completion response

Error message

Unexpected mistral completion response

What it means

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.

Source

Thrown at litellm/llms/bedrock/chat/invoke_transformations/amazon_mistral_transformation.py:109

        """This function extracts the output text from a bedrock mistral completion.
        As a side effect, it updates the finish reason for a model response.

        Args:
            completion_response: JSON from the completion.
            model_response: ModelResponse

        Returns:
            A string with the response of the LLM

        """
        if "choices" in completion_response:
            outputText = completion_response["choices"][0]["message"]["content"]
            model_response.choices[0].finish_reason = completion_response["choices"][0]["finish_reason"]
        elif "outputs" in completion_response:
            outputText = completion_response["outputs"][0]["text"]
            model_response.choices[0].finish_reason = completion_response["outputs"][0]["stop_reason"]
        else:
            raise BedrockError(message="Unexpected mistral completion response", status_code=400)

        return outputText

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Log the raw completion_response payload (set LITELLM_LOG=DEBUG) to see the actual schema returned.
  2. Switch to bedrock/converse/mistral.* - the Converse API response format is stable and avoids the legacy parser.
  3. Upgrade litellm if the model is new; support for new Mistral variants lands in the transformation config.
  4. Confirm the model ID exists in your region and is enabled (a disabled model can return an error body).

Example fix

# before
resp = litellm.completion(model="bedrock/mistral.mistral-7b-instruct-v0:2", messages=msgs)

# after
resp = litellm.completion(model="bedrock/converse/mistral.mistral-7b-instruct-v0:2", messages=msgs)
Defensive patterns

Strategy: fallback

Try / catch

from litellm.exceptions import BedrockError
try:
    resp = litellm.completion(model="bedrock/mistral.<model>", messages=msgs)
except BedrockError as e:
    if e.status_code == 400 and "Unexpected mistral" in str(e):
        resp = litellm.completion(model="bedrock/converse/mistral.<model>", messages=msgs)
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/593824907b93ff67. Report an issue: GitHub.