BerriAI/litellm · error · ValueError

Unknown BFL image generation model

Error message

Unknown BFL image generation model: {model_name}. Supported models: {list(IMAGE_GENERATION_MODELS.keys())}

What it means

BFL's transformation resolves the endpoint by lowercasing the model, stripping any 'provider/' prefix, and looking the remainder up in the IMAGE_GENERATION_MODELS dict. A name not in that dict raises this ValueError listing the supported models. LiteLLM therefore only routes BFL model names it explicitly knows.

Solutions

  1. Use one of the listed names from the error message itself (e.g. black_forest_labs/flux-pro-1.1).
  2. pip install -U litellm to pick up newly registered BFL models.
  3. Inspect the mapping: from litellm.llms.black_forest_labs.common_utils import IMAGE_GENERATION_MODELS; print(list(IMAGE_GENERATION_MODELS)).

Example fix

# before
litellm.image_generation(model="black_forest_labs/flux-pro", prompt="a cat")

# after
litellm.image_generation(model="black_forest_labs/flux-pro-1.1", prompt="a cat")
Defensive patterns

Strategy: validation

Validate before calling

from litellm.llms.black_forest_labs.common_utils import IMAGE_GENERATION_MODELS

def valid_bfl_model(model: str) -> bool:
    name = model.lower().split("/")[-1]
    return name in IMAGE_GENERATION_MODELS

Try / catch

try:
    litellm.image_generation(model=model, prompt=p)
except ValueError as e:
    if "Unknown BFL image generation model" in str(e):
        # fall back to a known-good model
        litellm.image_generation(model="black_forest_labs/flux-pro-1.1", prompt=p)
    else:
        raise

Prevention

When it happens

Trigger: model="black_forest_labs/flux-pro" (truncated name), "flux-1.1-pro" (wrong order), a newly released FLUX model not yet present in the installed litellm version, or an arbitrary string after the prefix.

Common situations: BFL ships a new model and users update the model string before updating litellm; mixing up BFL naming with other providers' conventions; case is forgiving (lowercased) but punctuation/order are not.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/91bb0091b5b455f0. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/black_forest_labs/image_generation/transformation.py:183

        headers["Content-Type"] = "application/json"
        headers["Accept"] = "application/json"

        return headers

    def _get_model_endpoint(self, model: str) -> str:
        """
        Get the API endpoint for a given model.
        """
        # Remove provider prefix if present (e.g., "black_forest_labs/flux-pro-1.1")
        model_name = model.lower()
        if "/" in model_name:
            model_name = model_name.split("/")[-1]

        # Check if model is in our mapping
        if model_name in IMAGE_GENERATION_MODELS:
            return IMAGE_GENERATION_MODELS[model_name]

        raise ValueError(
            f"Unknown BFL image generation model: {model_name}. "
            f"Supported models: {list(IMAGE_GENERATION_MODELS.keys())}"
        )

    def get_complete_url(
        self,
        api_base: str | None,
        api_key: str | None,
        model: str,
        optional_params: dict,
        litellm_params: dict,
        stream: bool | None = None,
    ) -> str:
        """
        Get the complete URL for the Black Forest Labs API request.
        """
        base_url: str = api_base or get_secret_str("BFL_API_BASE") or DEFAULT_API_BASE
        base_url = base_url.rstrip("/")

View on GitHub (pinned to 77b7c6c40c)