def invoke_model_with_retry(
    client: Any,
    model: str,
    messages: Dict[str, Any],
    max_retries: int = 3,
    **kwargs: Any,
) -> Any:
    """Use tenacity to retry the model invocation."""
    retry_decorator = _create_retry_decorator(client=client, max_retries=max_retries)

    @retry_decorator
    def _invoke_with_retry(**kwargs: Any) -> Any:
        return client.invoke_model(**kwargs)

    return _invoke_with_retry(
        modelId=model,
        body=messages,
        **kwargs,
    )
Use tenacity to retry the model invocation.
llama-index-integrations/multi_modal_llms/llama-index-multi-modal-llms-bedrock/llama_index/multi_modal_llms/bedrock/utils.py