{"record":{"id":"74b1804af89bdf95","repo":"BerriAI/litellm","slug":"api-base-is-required-for-azure-ai-flux-2-image-gen","errorCode":null,"errorMessage":"api_base is required for Azure AI FLUX 2 image generation","messagePattern":"api_base is required for Azure AI FLUX 2 image generation","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/azure_ai/image_generation/flux_transformation.py","lineNumber":39,"sourceCode":"        api_version: str | None,\n    ) -> str:\n        \"\"\"\n        Constructs the complete URL for Azure AI FLUX 2 image generation.\n\n        FLUX 2 models on Azure AI use a different URL pattern than standard Azure OpenAI:\n        - Standard: /openai/deployments/{model}/images/generations\n        - FLUX 2: /providers/blackforestlabs/v1/flux-2-pro\n\n        Args:\n            api_base: Base URL (e.g., https://litellm-ci-cd-prod.services.ai.azure.com)\n            model: Model name (e.g., flux.2-pro)\n            api_version: API version (e.g., preview)\n\n        Returns:\n            Complete URL for the FLUX 2 image generation endpoint\n        \"\"\"\n        if api_base is None:\n            raise ValueError(\"api_base is required for Azure AI FLUX 2 image generation\")\n\n        api_base = api_base.rstrip(\"/\")\n        api_version = api_version or \"preview\"\n\n        # If the api_base already contains /providers/, it's already a complete path\n        if \"/providers/\" in api_base:\n            if \"?\" in api_base:\n                return api_base\n            return f\"{api_base}?api-version={api_version}\"\n\n        # Construct the FLUX 2 provider path\n        # Model name flux.2-pro maps to endpoint flux-2-pro\n        return f\"{api_base}/providers/blackforestlabs/v1/flux-2-pro?api-version={api_version}\"\n\n    @staticmethod\n    def is_flux2_model(model: str) -> bool:\n        \"\"\"\n        Check if the model is an Azure AI FLUX 2 model.","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/azure_ai/image_generation/flux_transformation.py#L21-L57","documentation":"Error \"api_base is required for Azure AI FLUX 2 image generation\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/azure_ai/image_generation/flux_transformation.py:39 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass api_base for the Azure AI FLUX 2 image generation call."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}