{"record":{"id":"96a2ad30ea0da451","repo":"BerriAI/litellm","slug":"unknown-bfl-image-edit-model-model-name-suppor","errorCode":null,"errorMessage":"Unknown BFL image edit model: {model_name}. Supported models: {list(IMAGE_EDIT_MODELS.keys())}","messagePattern":"Unknown BFL image edit model: (.+?)\\. Supported models: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/black_forest_labs/image_edit/transformation.py","lineNumber":171,"sourceCode":"        \"\"\"\n        BFL uses JSON requests, not multipart/form-data.\n        \"\"\"\n        return False\n\n    def _get_model_endpoint(self, model: str) -> str:\n        \"\"\"\n        Get the API endpoint for a given model.\n        \"\"\"\n        # Remove provider prefix if present (e.g., \"black_forest_labs/flux-kontext-pro\")\n        model_name = model.lower()\n        if \"/\" in model_name:\n            model_name = model_name.split(\"/\")[-1]\n\n        # Check if model is in our mapping\n        if model_name in IMAGE_EDIT_MODELS:\n            return IMAGE_EDIT_MODELS[model_name]\n\n        raise ValueError(\n            f\"Unknown BFL image edit model: {model_name}. Supported models: {list(IMAGE_EDIT_MODELS.keys())}\"\n        )\n\n    def get_complete_url(\n        self,\n        model: str,\n        api_base: str | None,\n        litellm_params: dict,\n    ) -> str:\n        \"\"\"\n        Get the complete URL for the Black Forest Labs API request.\n        \"\"\"\n        base_url: str = api_base or get_secret_str(\"BFL_API_BASE\") or DEFAULT_API_BASE\n        base_url = base_url.rstrip(\"/\")\n\n        endpoint: Final = self._get_model_endpoint(model)\n        return f\"{base_url}{endpoint}\"\n","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/black_forest_labs/image_edit/transformation.py#L153-L189","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\nlitellm.image_edit(model=\"black_forest_labs/flux-pro-1.1\", image=img, prompt=\"...\")\n\n# after\nlitellm.image_edit(model=\"black_forest_labs/flux-kontext-pro\", image=img, prompt=\"...\")","handlingStrategy":"validation","validationCode":"from litellm.llms.black_forest_labs.image_edit.transformation import IMAGE_EDIT_MODELS\n\ndef norm(m): return m.lower().split(\"/\")[-1]\nassert norm(model) in IMAGE_EDIT_MODELS, f\"{model} not in {list(IMAGE_EDIT_MODELS)}\"","typeGuard":"def is_bfl_edit_model(model: str) -> bool:\n    return model.lower().split(\"/\")[-1] in IMAGE_EDIT_MODELS","tryCatchPattern":"try:\n    litellm.image_edit(model=model, image=img, prompt=p)\nexcept ValueError as e:\n    if \"Unknown BFL image edit model\" in str(e):\n        model = \"black_forest_labs/flux-kontext-pro\"  # fall back to known-good\n        litellm.image_edit(model=model, image=img, prompt=p)\n    else:\n        raise","preventionTips":["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."],"tags":["bfl","model-name","validation","image-edit"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}