BerriAI/litellm · error · ValueError
api_base is required for Azure AI FLUX 2 image generation
Error message
api_base is required for Azure AI FLUX 2 image generation
What it means
Error "api_base is required for Azure AI FLUX 2 image generation" thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/azure_ai/image_generation/flux_transformation.py:39
api_version: str | None,
) -> str:
"""
Constructs the complete URL for Azure AI FLUX 2 image generation.
FLUX 2 models on Azure AI use a different URL pattern than standard Azure OpenAI:
- Standard: /openai/deployments/{model}/images/generations
- FLUX 2: /providers/blackforestlabs/v1/flux-2-pro
Args:
api_base: Base URL (e.g., https://litellm-ci-cd-prod.services.ai.azure.com)
model: Model name (e.g., flux.2-pro)
api_version: API version (e.g., preview)
Returns:
Complete URL for the FLUX 2 image generation endpoint
"""
if api_base is None:
raise ValueError("api_base is required for Azure AI FLUX 2 image generation")
api_base = api_base.rstrip("/")
api_version = api_version or "preview"
# If the api_base already contains /providers/, it's already a complete path
if "/providers/" in api_base:
if "?" in api_base:
return api_base
return f"{api_base}?api-version={api_version}"
# Construct the FLUX 2 provider path
# Model name flux.2-pro maps to endpoint flux-2-pro
return f"{api_base}/providers/blackforestlabs/v1/flux-2-pro?api-version={api_version}"
@staticmethod
def is_flux2_model(model: str) -> bool:
"""
Check if the model is an Azure AI FLUX 2 model.View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass api_base for the Azure AI FLUX 2 image generation call.
When it happens
Trigger: Thrown at litellm/llms/azure_ai/image_generation/flux_transformation.py:39 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/74b1804af89bdf95.
Report an issue: GitHub.