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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Add support for stability speicifc params in request
Sameer Kankute5feb6d538854
diff --git a/litellm/images/main.py b/litellm/images/main.pyindex 49d2026100e..1075d298bdf 100644--- a/litellm/images/main.py+++ b/litellm/images/main.py@@ -696,6 +696,29 @@ def image_edit("""local_vars = locals()try:+ openai_params = [+ "user",+ "request_timeout",+ "api_base",+ "api_version",+ "api_key",+ "deployment_id",+ "organization",+ "base_url",+ "default_headers",+ "timeout",+ "max_retries",+ "n",+ "quality",+ "size",+ "style",+ "async_call",+ ]+ litellm_params = all_litellm_params+ default_params = openai_params + litellm_params+ non_default_params = {+ k: v for k, v in kwargs.items() if k not in default_params+ } # model-specific params - pass them straight to the model/providerlitellm_logging_obj: LiteLLMLoggingObj = kwargs.get("litellm_logging_obj") # type: ignorelitellm_call_id: Optional[str] = kwargs.get("litellm_call_id", None)_is_async = kwargs.pop("async_call", False) is True@@ -789,7 +812,6 @@ def image_edit(image_edit_optional_params: ImageEditOptionalRequestParams = (_get_ImageEditRequestUtils().get_requested_image_edit_optional_param(local_vars))-# Get optional parameters for the responses APIimage_edit_request_params: Dict = (_get_ImageEditRequestUtils().get_optional_params_image_edit(@@ -831,7 +853,23 @@ def image_edit(extra_headers=extra_headers,api_key=kwargs.get("api_key"),)-+ elif custom_llm_provider == "stability":+ image_edit_request_params.update(non_default_params)+ return base_llm_http_handler.image_edit_handler(+ model=model,+ image=images,+ prompt=prompt,+ image_edit_provider_config=image_edit_provider_config,+ image_edit_optional_request_params=image_edit_request_params,+ custom_llm_provider=custom_llm_provider,+ litellm_params=litellm_params,+ logging_obj=litellm_logging_obj,+ extra_headers=extra_headers,+ extra_body=extra_body,+ timeout=timeout or DEFAULT_REQUEST_TIMEOUT,+ _is_async=_is_async,+ client=kwargs.get("client"),+ )# Call the handler with _is_async flag instead of directly calling the async handlerreturn base_llm_http_handler.image_edit_handler(model=model,diff --git a/litellm/llms/stability/image_edit/__init__.py b/litellm/llms/stability/image_edit/__init__.pyindex 7710f080168..5a9eb2e02b9 100644--- a/litellm/llms/stability/image_edit/__init__.py+++ b/litellm/llms/stability/image_edit/__init__.py@@ -8,7 +8,7 @@ from litellm.llms.base_llm.image_edit.transformation import (BaseImageEditConfig,)-from .transformation import StabilityImageEditConfig+from .transformations import StabilityImageEditConfig__all__ = ["StabilityImageEditConfig",diff --git a/litellm/llms/stability/image_edit/transformations.py b/litellm/llms/stability/image_edit/transformations.pyindex fabd1e72054..6e5915c8afe 100644--- a/litellm/llms/stability/image_edit/transformations.py+++ b/litellm/llms/stability/image_edit/transformations.py@@ -91,7 +91,7 @@ class StabilityImageEditConfig(BaseImageEditConfig):mapped_params["_n"] = velif k == "response_format":# Only b64 supported at Stability; store for postprocessing- mapped_params["_response_format"] = v+ mapped_params["output_format"] = velif k not in supported_params:if not drop_params:raise ValueError(@@ -209,11 +209,22 @@ class StabilityImageEditConfig(BaseImageEditConfig):"negative_prompt","aspect_ratio","seed",- "output_format",- "model","mode","strength","style_preset",+ "left",+ "bottom",+ "right",+ "top",+ "creativity",+ "search_prompt",+ "grow_mask",+ "select_prompt",+ "control_strength",+ "init_image",+ "style_image",+ "composition_fidelity",+ "change_strength"]:data[key] = value # type: ignore