BerriAI/litellm · error · ValueError
Unknown BFL image edit model: {model_name}. Supported models
Error message
Unknown BFL image edit model: {model_name}. Supported models: {list(IMAGE_EDIT_MODELS.keys())} What it means
The BFL image-edit transformation maps model names to endpoints via the IMAGE_EDIT_MODELS dict. After lowercasing and stripping any provider prefix (e.g. 'black_forest_labs/flux-kontext-pro' -> 'flux-kontext-pro'), an unknown name raises plain ValueError listing the supported models. It fires before any request is sent, so no API quota is consumed.
Source
Thrown at litellm/llms/black_forest_labs/image_edit/transformation.py:171
"""
BFL uses JSON requests, not multipart/form-data.
"""
return False
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-kontext-pro")
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_EDIT_MODELS:
return IMAGE_EDIT_MODELS[model_name]
raise ValueError(
f"Unknown BFL image edit model: {model_name}. Supported models: {list(IMAGE_EDIT_MODELS.keys())}"
)
def get_complete_url(
self,
model: str,
api_base: str | None,
litellm_params: dict,
) -> 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("/")
endpoint: Final = self._get_model_endpoint(model)
return f"{base_url}{endpoint}"
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Use a model present in IMAGE_EDIT_MODELS — typically 'black_forest_labs/flux-kontext-pro' or 'black_forest_labs/flux-kontext-max' (the error message prints the exact supported list; match it).
- If you intended text-to-image rather than editing, call litellm.image_generation with the generation model instead.
- Upgrade LiteLLM if BFL shipped a new edit model that your version does not map yet.
- Check for typos and stray whitespace in the model string.
Example fix
# before litellm.image_edit(model="black_forest_labs/flux-pro-1.1", image=img, prompt="...") # after litellm.image_edit(model="black_forest_labs/flux-kontext-pro", image=img, prompt="...")
Defensive patterns
Strategy: validation
Validate before calling
from litellm.llms.black_forest_labs.image_edit.transformation import IMAGE_EDIT_MODELS
def norm(m): return m.lower().split("/")[-1]
assert norm(model) in IMAGE_EDIT_MODELS, f"{model} not in {list(IMAGE_EDIT_MODELS)}" Type guard
def is_bfl_edit_model(model: str) -> bool:
return model.lower().split("/")[-1] in IMAGE_EDIT_MODELS Try / catch
try:
litellm.image_edit(model=model, image=img, prompt=p)
except ValueError as e:
if "Unknown BFL image edit model" in str(e):
model = "black_forest_labs/flux-kontext-pro" # fall back to known-good
litellm.image_edit(model=model, image=img, prompt=p)
else:
raise Prevention
- Keep a module-level constant of supported edit models instead of raw strings.
- Pin model names from IMAGE_EDIT_MODELS, not from marketing docs.
- Test model strings in CI with a no-network unit test that calls _get_model_endpoint.
When it happens
Trigger: Calling image_edit with model set to a name not in IMAGE_EDIT_MODELS — e.g. a generation-only model like 'flux-pro-1.1' used with image_edit, a typo such as 'flux-kontext-proo', or an unlisted casing variant (matching is lowercase).
Common situations: Confusing image generation models with image edit models (only the kontext family supports edit); using a model string from BFL docs that LiteLLM has not mapped yet (version skew after BFL releases new models); copy-paste typos; omitting or mistyping the provider prefix is fine, but the suffix must match exactly.
Related errors
- Unknown BFL image generation model: {model_name}. Supported
- Invalid arg. Model cannot be none.
- Model {model} is not supported for Azure AI image editing.
- OUTPAINTING requires either a mask image or a mask prompt. P
- Unsupported Amazon Nova Canvas taskType: {task_type!r}. Use
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/96a2ad30ea0da451.
Report an issue: GitHub.