diff --git a/flux2_test_image.png b/flux2_test_image.png new file mode 100644 index 00000000000..d40fa1a65f2 Binary files /dev/null and b/flux2_test_image.png differ diff --git a/litellm/llms/azure/azure.py b/litellm/llms/azure/azure.py index 994afa26e9c..ec4553fac4f 100644 --- a/litellm/llms/azure/azure.py +++ b/litellm/llms/azure/azure.py @@ -990,6 +990,10 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): def create_azure_base_url( self, azure_client_params: dict, model: Optional[str] ) -> str: + from litellm.llms.azure_ai.image_generation import ( + AzureFoundryFluxImageGenerationConfig, + ) + api_base: str = azure_client_params.get( "azure_endpoint", "" ) # "https://example-endpoint.openai.azure.com" @@ -999,6 +1003,15 @@ class AzureChatCompletion(BaseAzureLLM, BaseLLM): if model is None: model = "" + # Handle FLUX 2 models on Azure AI which use a different URL pattern + # e.g., /providers/blackforestlabs/v1/flux-2-pro instead of /openai/deployments/{model}/images/generations + if AzureFoundryFluxImageGenerationConfig.is_flux2_model(model): + return AzureFoundryFluxImageGenerationConfig.get_flux2_image_generation_url( + api_base=api_base, + model=model, + api_version=api_version, + ) + if "/openai/deployments/" in api_base: base_url_with_deployment = api_base else: diff --git a/test_image_edit.png b/test_image_edit.png new file mode 100644 index 00000000000..0f2de3749df Binary files /dev/null and b/test_image_edit.png differ