BerriAI/litellm · error · ValueError

Invalid image variation provider: {custom_llm_provider}. Sup

Error message

Invalid image variation provider: {custom_llm_provider}. Supported providers are: {LITELLM_IMAGE_VARIATION_PROVIDERS}

What it means

image_variations() only supports providers listed in the LITELLM_IMAGE_VARIATION_PROVIDERS enum (currently OpenAI and Topaz). The code converts the routed provider into that enum at litellm/images/main.py:636; any other provider raises ValueError listing the supported set.

Source

Thrown at litellm/images/main.py:638

    # get logging object
    litellm_logging_obj: Final = cast(LiteLLMLoggingObj, kwargs.get("litellm_logging_obj"))

    # get the litellm params
    litellm_params: Final = get_litellm_params(**kwargs)
    # get the custom llm provider
    model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider(
        model=model,
        custom_llm_provider=litellm_params.get("custom_llm_provider", None),
        api_base=litellm_params.get("api_base", None),
        api_key=litellm_params.get("api_key", None),
    )

    # route to the correct provider w/ the params
    try:
        llm_provider: Final = LlmProviders(custom_llm_provider)
        image_variation_provider: Final = LITELLM_IMAGE_VARIATION_PROVIDERS(llm_provider)
    except ValueError:
        raise ValueError(
            f"Invalid image variation provider: {custom_llm_provider}. Supported providers are: {LITELLM_IMAGE_VARIATION_PROVIDERS}"
        )
    model_response: Final = ImageResponse()

    response: ImageResponse | None = None

    provider_config: Final = ProviderConfigManager.get_provider_model_info(
        model=model or "",  # openai defaults to dall-e-2
        provider=llm_provider,
    )

    if provider_config is None:
        raise ValueError(
            f"image variation provider has no known model info config - required for getting api keys, etc.: {custom_llm_provider}. Supported providers are: {LITELLM_IMAGE_VARIATION_PROVIDERS}"
        )

    api_key: Final = provider_config.get_api_key(litellm_params.get("api_key", None))
    api_base = provider_config.get_api_base(litellm_params.get("api_base", None))

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Use OpenAI (dall-e-2) or Topaz for image variations: model='dall-e-2' or model='topaz/topaz-image-alter-v1'
  2. For other providers, call the underlying variation API directly or use image_edit where supported
  3. Upgrade litellm — variation provider support may expand

Example fix

# before
litellm.image_variations(model="stability/sd3.5", image="cat.png")

# after
litellm.image_variations(model="dall-e-2", image="cat.png")
Defensive patterns

Strategy: type-guard

Validate before calling

SUPPORTED_VARIATION_PROVIDERS = {"openai", "topaz"}

def can_variation(provider: str) -> bool:
    return provider in SUPPORTED_VARIATION_PROVIDERS

Type guard

from litellm.types.utils import LITELLM_IMAGE_VARIATION_PROVIDERS
from litellm.constants import LlmProviders

def is_variation_provider(model_or_provider: str) -> bool:
    provider = model_or_provider.split("/", 1)[0]
    try:
        return LlmProviders(provider) in [p.value for p in LITELLM_IMAGE_VARIATION_PROVIDERS]
    except ValueError:
        return False

Try / catch

try:
    r = litellm.image_variations(model=m, image=img)
except ValueError as e:
    if "Invalid image variation provider" in str(e):
        # switch to dall-e-2 or a Topaz model, or surface unsupported to the user
        raise

Prevention

When it happens

Trigger: Calling litellm.image_variations(image=..., model='replicate/...') or with custom_llm_provider for any provider other than openai/topaz; using the 'provider/model' prefix of an unsupported provider.

Common situations: Developer assumes image_variations works everywhere image_generation does (vertex, azure, etc.); or migration code reuses the image_generation provider list for variations.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/b48b746a70624657. Report an issue: GitHub.