{"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":"validation","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/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/images/main.py#L393-L429","documentation":"The black_forest_labs (FLUX) image route requires an explicit model because it delegates to bfl_image_generation.image_generation, which needs the model name to pick the BFL API endpoint and polling behavior. litellm only auto-defaults model to 'dall-e-2'/openai when BOTH model and custom_llm_provider are None (litellm/images/main.py:224-232), so a provider set without a model reaches this guard as None.","triggerScenarios":"litellm.image_generation(prompt='...', custom_llm_provider='black_forest_labs') with no model; a Router/proxy deployment whose model entry sets litellm_params.custom_llm_provider='black_forest_labs' but leaves model empty; passing model=None explicitly while relying on the provider kwarg.","commonSituations":"Proxy config yaml with a model_name but a missing/blank model field under litellm_params; copy-pasted chat-style invocations where the provider is a separate argument and the model string was omitted; assuming litellm defaults a model per provider.","solutions":["Pass a BFL model, ideally provider-prefixed: litellm.image_generation(model='black_forest_labs/flux-pro-1.1', prompt='...') so both provider and model resolve from one string.","If provider is passed separately, still supply model='flux-pro-1.1' (or flux-dev / flux-kontext variants).","In proxy/Router config, verify the model entry has a concrete model value, not just model_name + custom_llm_provider."],"exampleFix":"# before\nresp = litellm.image_generation(prompt=\"a cat\", custom_llm_provider=\"black_forest_labs\")\n# Exception: Model needs to be set for black_forest_labs\n\n# after\nresp = litellm.image_generation(model=\"black_forest_labs/flux-pro-1.1\", prompt=\"a cat\")","handlingStrategy":"validation","validationCode":"def call_bfl(prompt: str, model: str | None = None):\n    model = model or \"black_forest_labs/flux-pro-1.1\"\n    if model is None or model.strip() == \"\":\n        raise ValueError(\"model is required for black_forest_labs image generation\")\n    return litellm.image_generation(model=model, prompt=prompt)","typeGuard":"def is_bfl_ready(model: str | None, custom_llm_provider: str | None) -> bool:\n    \"\"\"True when the call cannot hit the 'Model needs to be set' guard.\"\"\"\n    if custom_llm_provider == \"black_forest_labs\":\n        return isinstance(model, str) and model.strip() != \"\"\n    return True","tryCatchPattern":"try:\n    resp = litellm.image_generation(prompt=p, custom_llm_provider=\"black_forest_labs\")\nexcept Exception as e:\n    if \"Model needs to be set for black_forest_labs\" in str(e):\n        raise ValueError(\"pass model='black_forest_labs/flux-pro-1.1' (or another FLUX model)\") from e\n    raise","preventionTips":["Standardize on provider-prefixed model strings ('black_forest_labs/flux-...') so the model can never be None.","Validate proxy/Router model entries with a schema requiring a non-empty model field.","Unit-test your image wrapper with None-model inputs to assert it fails fast with your own message."],"tags":["litellm","image-generation","black-forest-labs","flux","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}