diff --git a/litellm/llms/openai_like/chat/handler.py b/litellm/llms/openai_like/chat/handler.py index 821fc9b7f15..25b7fc2e98c 100644 --- a/litellm/llms/openai_like/chat/handler.py +++ b/litellm/llms/openai_like/chat/handler.py @@ -272,7 +272,11 @@ class OpenAILikeChatHandler(OpenAILikeBase): ) data = { - "model": model, + # watsonx: Deployment models do not support 'model_id' in their payload + # https://github.com/BerriAI/litellm/issues/11837 + "model": None + if custom_llm_provider == "watsonx" and model.startswith("deployment/") + else model, "messages": messages, **optional_params, **extra_body, diff --git a/tests/llm_translation/test_watsonx.py b/tests/llm_translation/test_watsonx.py index e0c125a9017..e399c6de7a9 100644 --- a/tests/llm_translation/test_watsonx.py +++ b/tests/llm_translation/test_watsonx.py @@ -207,6 +207,7 @@ def test_watsonx_deployment_space_id(monkeypatch, watsonx_chat_completion_call, assert mock_post.call_count == 1 json_data = json.loads(mock_post.call_args.kwargs["data"]) assert my_fake_space_id not in json_data + assert json_data.get("model") is None def test_watsonx_deployment_space_id_embedding(monkeypatch, watsonx_embedding_call): @@ -218,3 +219,4 @@ def test_watsonx_deployment_space_id_embedding(monkeypatch, watsonx_embedding_ca assert mock_post.call_count == 1 json_data = json.loads(mock_post.call_args.kwargs["data"]) assert my_fake_space_id not in json_data + assert json_data.get("model") is None