{"record":{"id":"b48b746a70624657","repo":"BerriAI/litellm","slug":"invalid-image-variation-provider-custom-llm-prov","errorCode":null,"errorMessage":"Invalid image variation provider: {custom_llm_provider}. Supported providers are: {LITELLM_IMAGE_VARIATION_PROVIDERS}","messagePattern":"Invalid image variation provider: (.+?)\\. Supported providers are: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/images/main.py","lineNumber":638,"sourceCode":"    # get logging object\n    litellm_logging_obj: Final = cast(LiteLLMLoggingObj, kwargs.get(\"litellm_logging_obj\"))\n\n    # get the litellm params\n    litellm_params: Final = get_litellm_params(**kwargs)\n    # get the custom llm provider\n    model, custom_llm_provider, dynamic_api_key, api_base = get_llm_provider(\n        model=model,\n        custom_llm_provider=litellm_params.get(\"custom_llm_provider\", None),\n        api_base=litellm_params.get(\"api_base\", None),\n        api_key=litellm_params.get(\"api_key\", None),\n    )\n\n    # route to the correct provider w/ the params\n    try:\n        llm_provider: Final = LlmProviders(custom_llm_provider)\n        image_variation_provider: Final = LITELLM_IMAGE_VARIATION_PROVIDERS(llm_provider)\n    except ValueError:\n        raise ValueError(\n            f\"Invalid image variation provider: {custom_llm_provider}. Supported providers are: {LITELLM_IMAGE_VARIATION_PROVIDERS}\"\n        )\n    model_response: Final = ImageResponse()\n\n    response: ImageResponse | None = None\n\n    provider_config: Final = ProviderConfigManager.get_provider_model_info(\n        model=model or \"\",  # openai defaults to dall-e-2\n        provider=llm_provider,\n    )\n\n    if provider_config is None:\n        raise ValueError(\n            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}\"\n        )\n\n    api_key: Final = provider_config.get_api_key(litellm_params.get(\"api_key\", None))\n    api_base = provider_config.get_api_base(litellm_params.get(\"api_base\", None))","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/images/main.py#L620-L656","documentation":"litellm.image_variation only supports providers listed in the LITELLM_IMAGE_VARIATION_PROVIDERS enum, which currently contains exactly OPENAI and TOPAZ (litellm/types/utils.py:3828-3834). The code first converts the provider to LlmProviders then to LITELLM_IMAGE_VARIATION_PROVIDERS; any other provider (stability, gemini, bedrock, ...) fails that enum conversion and raises this ValueError.","triggerScenarios":"litellm.image_variation(model='stability/stable-diffusion-xl-...', image=image) or any provider-prefixed model whose provider is not openai/topaz; passing custom_llm_provider explicitly for an unsupported provider; calling image_variation on a model string that get_llm_provider maps to something other than openai or topaz.","commonSituations":"Assuming the image_variation endpoint has parity with image_generation providers; migrating code from image_generation (many providers) to image_variation (two); using a proxy model name that infers a non-openai provider.","solutions":["Use an OpenAI model (dall-e-2 is the classic variation model) via model='openai/dall-e-2' or the plain 'dall-e-2' default.","Use Topaz: model='topaz/...' with TOPAZ credentials.","For other providers, call their native variation/edit API directly instead of litellm.image_variation.","Watch litellm release notes and upgrade — the enum grows over time, then re-test."],"exampleFix":"# before\nresp = litellm.image_variation(model=\"stability/stable-diffusion-xl-1024-v1-0\", image=img)\n# ValueError: Invalid image variation provider: stability ...\n\n# after\nresp = litellm.image_variation(model=\"dall-e-2\", image=img)  # openai path","handlingStrategy":"validation","validationCode":"from litellm.types.utils import LITELLM_IMAGE_VARIATION_PROVIDERS\nfrom litellm import LlmProviders\n\nSUPPORTED = {p.value for p in LITELLM_IMAGE_VARIATION_PROVIDERS}\n\ndef can_variation(provider: str) -> bool:\n    return provider in SUPPORTED\n\nassert can_variation(\"openai\") and can_variation(\"topaz\")  # only these pass","typeGuard":"from litellm.types.utils import LITELLM_IMAGE_VARIATION_PROVIDERS\n\ndef is_supported_variation_provider(provider: str) -> bool:\n    \"\"\"Type/narrowing guard: True only for providers with a wired image_variation branch.\"\"\"\n    try:\n        LITELLM_IMAGE_VARIATION_PROVIDERS(LlmProviders(provider))\n        return True\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    resp = litellm.image_variation(model=model, image=img)\nexcept ValueError as e:\n    if \"Invalid image variation provider\" in str(e):\n        # fall back to an OpenAI variation model or the provider's native API\n        resp = litellm.image_variation(model=\"dall-e-2\", image=img)\n    else:\n        raise","preventionTips":["Treat image_variation support as an allowlist (openai, topaz) — never assume parity with image_generation.","Gate variation features behind a config flag listing supported providers.","Re-run an allowlist check after every litellm upgrade since the enum grows over time."],"tags":["litellm","image-variation","unsupported-provider","openai","topaz"],"backgroundTag":"unsupported-provider","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}