BerriAI/litellm · error · ValueError

Unknown BFL image generation model: {model_name}. Supported

Error message

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

What it means

_get_model_endpoint lowercases the model name, strips any provider prefix (text after the last '/'), and looks the remainder up in the IMAGE_GENERATION_MODELS dict. No match raises this ValueError listing the supported models. It is a client-side routing error: the request never leaves the machine.

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 6c2dcb801b)

Solutions

  1. Use a model id from the error message's supported list, with or without the provider prefix (e.g. 'black_forest_labs/flux-pro-1.1' or 'flux-pro-1.1').
  2. Upgrade litellm if the model is newly released by BFL: pip install -U litellm.
  3. Check litellm's BFL docs / IMAGE_GENERATION_MODELS for the canonical ids.

Example fix

# before
litellm.images.generate(model="bfl/flux-2-pro", prompt=p)

# after
litellm.images.generate(model="black_forest_labs/flux-pro-1.1", prompt=p)
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_BFL = {"flux-pro-1.1", "flux-dev", "flux-pro-1.1-ultra", "flux-kontext-pro"}  # sync with litellm version
if model.split("/")[-1].lower() not in SUPPORTED_BFL:
    raise ValueError(f"model '{model}' not registered for BFL; choices: {sorted(SUPPORTED_BFL)}")

Type guard

def is_bfl_model_supported(model: str) -> bool:
    return model.lower().split("/")[-1] in get_bfl_supported_models()  # mirror IMAGE_GENERATION_MODELS keys

Try / catch

try:
    litellm.images.generate(model=model, prompt=p)
except ValueError as e:
    if "Unknown BFL image generation model" in str(e):
        model = fallback_default_bfl_model  # pick from the listed supported models
        litellm.images.generate(model=model, prompt=p)
    else:
        raise

Prevention

When it happens

Trigger: model="bfl/flux-2" or "flux-pro" (names not in the mapping) instead of supported entries like "flux-pro-1.1"; typo in the model id; using a newly released BFL model on an older litellm that lacks the mapping.

Common situations: Model-name guesses from BFL marketing pages that don't match litellm's registered ids; stale litellm versions missing new models; passing the full endpoint URL as the model.

Related errors


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