Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(hosted_vllm): reject image edit params vLLM-Omni ignores

mateo-berric66ae07e3bb9
diff --git a/litellm/llms/hosted_vllm/image_edit/transformation.py b/litellm/llms/hosted_vllm/image_edit/transformation.py
index fa8c1dbfcfd..3b8cc437168 100644
--- a/litellm/llms/hosted_vllm/image_edit/transformation.py
+++ b/litellm/llms/hosted_vllm/image_edit/transformation.py
@@ -3,8 +3,17 @@ from typing import Final
from litellm.llms.openai.image_edit.transformation import OpenAIImageEditConfig
from litellm.secret_managers.main import get_secret_str
+PARAMS_VLLM_OMNI_DOES_NOT_ACCEPT: Final = frozenset({"mask", "quality", "input_fidelity"})
+
class HostedVLLMImageEditConfig(OpenAIImageEditConfig):
+ def get_supported_openai_params(self, model: str) -> list: # mutable-ok: BaseImageEditConfig contract
+ return [ # mutable-ok: BaseImageEditConfig returns list
+ param
+ for param in super().get_supported_openai_params(model)
+ if param not in PARAMS_VLLM_OMNI_DOES_NOT_ACCEPT
+ ]
+
def validate_environment(
self,
headers: dict, # mutable-ok: BaseImageEditConfig contract
diff --git a/litellm/utils.py b/litellm/utils.py
index 0f2b2f9042d..fc530f14e28 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -9239,7 +9239,7 @@ class ProviderConfigManager:
from litellm.llms.openai.image_edit import get_openai_image_edit_config
return get_openai_image_edit_config(model=model)
- if LlmProviders.HOSTED_VLLM == provider:
+ elif LlmProviders.HOSTED_VLLM == provider:
from litellm.llms.hosted_vllm.image_edit import get_hosted_vllm_image_edit_config
return get_hosted_vllm_image_edit_config(model=model)
diff --git a/tests/test_litellm/llms/hosted_vllm/image_edit/test_hosted_vllm_image_edit_transformation.py b/tests/test_litellm/llms/hosted_vllm/image_edit/test_hosted_vllm_image_edit_transformation.py
index 5646f3d9d13..bc0ea23e249 100644
--- a/tests/test_litellm/llms/hosted_vllm/image_edit/test_hosted_vllm_image_edit_transformation.py
+++ b/tests/test_litellm/llms/hosted_vllm/image_edit/test_hosted_vllm_image_edit_transformation.py
@@ -110,3 +110,46 @@ def test_image_edit_posts_multipart_to_vllm_omni():
assert f'name="model"\r\n\r\n{MODEL}'.encode() in request.content
assert b'name="prompt"\r\n\r\nadd a hat' in request.content
assert b'name="seed"\r\n\r\n42' in request.content
+
+
[email protected]("param", ["mask", "quality", "input_fidelity"])
+def test_params_vllm_omni_ignores_are_not_advertised(param: str):
+ supported = HostedVLLMImageEditConfig().get_supported_openai_params(MODEL)
+
+ assert param not in supported
+ assert {"image", "prompt", "n", "size", "response_format", "background", "user"} <= set(supported)
+
+
+def test_image_edit_rejects_quality_unless_dropped():
+ captured: list[httpx.Request] = []
+
+ def handler(request: httpx.Request) -> httpx.Response:
+ captured.append(request)
+ return httpx.Response(200, json={"created": 1712697600, "data": [{"b64_json": "aW1n"}]})
+
+ client = HTTPHandler(client=httpx.Client(transport=httpx.MockTransport(handler)))
+
+ with pytest.raises(litellm.UnsupportedParamsError, match="quality"):
+ litellm.image_edit(
+ model=f"hosted_vllm/{MODEL}",
+ image=PNG_BYTES,
+ prompt="add a hat",
+ api_base="http://localhost:8091",
+ client=client,
+ quality="low",
+ )
+ assert captured == []
+
+ litellm.image_edit(
+ model=f"hosted_vllm/{MODEL}",
+ image=PNG_BYTES,
+ prompt="add a hat",
+ api_base="http://localhost:8091",
+ client=client,
+ quality="low",
+ drop_params=True,
+ )
+
+ assert len(captured) == 1
+ assert b'name="quality"' not in captured[0].content
+ assert b'name="prompt"\r\n\r\nadd a hat' in captured[0].content