{"record":{"id":"51ff9aeebde741a0","repo":"BerriAI/litellm","slug":"model-needs-to-be-set-for-black-forest-labs","errorCode":null,"errorMessage":"Model needs to be set for black_forest_labs","messagePattern":"Model needs to be set for black_forest_labs","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/images/main.py","lineNumber":411,"sourceCode":"            _api_base: Final = api_base or litellm.api_base\n            litellm_params_dict[\"api_base\"] = _api_base\n\n            return llm_http_handler.image_generation_handler(\n                api_key=api_key,\n                model=model,\n                prompt=prompt,\n                image_generation_provider_config=image_generation_config,\n                image_generation_optional_request_params=optional_params,\n                custom_llm_provider=custom_llm_provider,\n                litellm_params=litellm_params_dict,\n                logging_obj=litellm_logging_obj,\n                timeout=timeout,\n                client=client,\n            )\n        elif custom_llm_provider == \"black_forest_labs\":\n            # Route to BFL-specific handler (polling required)\n            if model is None:\n                raise Exception(\"Model needs to be set for black_forest_labs\")\n            return bfl_image_generation.image_generation(\n                model=model,\n                prompt=prompt,\n                model_response=model_response,\n                optional_params=optional_params,\n                litellm_params=litellm_params_dict,\n                logging_obj=litellm_logging_obj,\n                timeout=timeout,\n                extra_headers=extra_headers,\n                client=client,\n                aimg_generation=aimg_generation,\n            )\n        elif custom_llm_provider == \"azure_ai\":\n            from litellm.llms.azure_ai.common_utils import AzureFoundryModelInfo\n\n            api_base = AzureFoundryModelInfo.get_api_base(api_base)\n            api_key = AzureFoundryModelInfo.get_api_key(api_key)\n            if extra_headers is not None:","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/images/main.py#L393-L429","documentation":"The Black Forest Labs (FLUX) image route requires polling of an asynchronous job API, so litellm must know which BFL model to submit. At litellm/images/main.py:411, if custom_llm_provider=='black_forest_labs' and the resolved model is None, it raises this Exception because there is no default FLUX model to fall back to.","triggerScenarios":"Calling litellm.image_generation(prompt=..., custom_llm_provider='black_forest_labs') with no model argument; or passing a model string that get_llm_provider could not split into provider/model, leaving model=None; or setting model=None explicitly.","commonSituations":"Developer assumes a default image model exists (as with some OpenAI paths), passes only a prompt; or the model string was consumed into provider detection ('black_forest_labs/' with nothing after the slash).","solutions":["Pass an explicit BFL model, e.g. model='black_forest_labs/flux-pro-1.0' or model='flux-dev' with custom_llm_provider='black_forest_labs'","Verify the model string has a non-empty part after the provider prefix","Set the BFL API key (BFL_API_KEY or api_key=) so routing succeeds on retry"],"exampleFix":"# before\nlitellm.image_generation(prompt=\"a cat\", custom_llm_provider=\"black_forest_labs\")\n\n# after\nlitellm.image_generation(model=\"black_forest_labs/flux-pro-1.0\", prompt=\"a cat\")","handlingStrategy":"validation","validationCode":"BFL_MODELS = {\"flux-pro-1.0\", \"flux-dev\", \"flux-pro-1.1\", \"flux-kontext-pro\"}\n\ndef validate_bfl_call(model: str | None) -> str:\n    if model is None:\n        raise ValueError(\"model is required for black_forest_labs image generation\")\n    bare = model.split(\"/\", 1)[-1]\n    assert bare in BFL_MODELS, f\"unknown BFL model: {model}\"\n    return model","typeGuard":"def is_bfl_ready(model: str | None) -> bool:\n    return model is not None and len(model.split('/', 1)[-1]) > 0","tryCatchPattern":"try:\n    img = litellm.image_generation(model=m, prompt=p, custom_llm_provider=\"black_forest_labs\")\nexcept Exception as e:\n    if \"Model needs to be set\" in str(e):\n        # fail fast at call site with a clear message\n        raise TypeError(\"BFL image generation requires an explicit model\") from e\n    raise","preventionTips":["Never call provider-specific image endpoints without an explicit model","Model required-parameters are cheap to check before the SDK call","Centralize model constants instead of passing user input straight through"],"tags":["image-generation","black-forest-labs","required-parameter"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}