mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-11 08:38:24 +00:00
fix(images): forward max_retries to the OpenAI image generation client
Per-call, deployment and default_litellm_params max_retries were filtered out before reaching the OpenAI-compatible image handler, which then always used 2 SDK retries. Forward the caller's value, and pin it to 0 for routed calls so the Router stays the only retry owner, matching completion() Co-authored-by: Ericz <yonglzh@gmail.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
6b2f9d7114
commit
4d85e08fac
1 changed files with 6 additions and 1 deletions
|
|
@ -284,6 +284,8 @@ def image_generation(
|
|||
extra_headers: Final = kwargs.get("extra_headers", None)
|
||||
headers: Final[dict] = kwargs.get("headers", None) or {}
|
||||
base_model: Final = kwargs.get("base_model", None)
|
||||
max_retries: Final = kwargs.get("max_retries")
|
||||
is_router_call: Final = any("model_group" in (kwargs.get(k) or ()) for k in ("metadata", "litellm_metadata"))
|
||||
if extra_headers is not None:
|
||||
headers.update(extra_headers)
|
||||
model_response: ImageResponse = litellm.utils.ImageResponse()
|
||||
|
|
@ -550,6 +552,7 @@ def image_generation(
|
|||
optional_params["extra_headers"] = extra_headers
|
||||
# Forward OpenAI organization if present (set by proxy pre-call utils)
|
||||
organization: Final[str | None] = kwargs.get("organization", None)
|
||||
sdk_max_retries: Final = 0 if is_router_call else max_retries
|
||||
model_response = openai_chat_completions.image_generation(
|
||||
model=model,
|
||||
prompt=prompt,
|
||||
|
|
@ -557,7 +560,9 @@ def image_generation(
|
|||
api_key=api_key or dynamic_api_key,
|
||||
api_base=api_base,
|
||||
logging_obj=litellm_logging_obj,
|
||||
optional_params=optional_params,
|
||||
optional_params=(
|
||||
optional_params if sdk_max_retries is None else {**optional_params, "max_retries": sdk_max_retries}
|
||||
),
|
||||
model_response=model_response,
|
||||
organization=organization,
|
||||
aimg_generation=aimg_generation,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue