diff --git a/docs/my-website/docs/providers/azure_ai_img.md b/docs/my-website/docs/providers/azure_ai_img.md new file mode 100644 index 0000000000..8e2f522686 --- /dev/null +++ b/docs/my-website/docs/providers/azure_ai_img.md @@ -0,0 +1,266 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Azure AI Image Generation + +Azure AI provides powerful image generation capabilities using FLUX models from Black Forest Labs to create high-quality images from text descriptions. + +## Overview + +| Property | Details | +|----------|---------| +| Description | Azure AI Image Generation uses FLUX models to generate high-quality images from text descriptions. | +| Provider Route on LiteLLM | `azure_ai/` | +| Provider Doc | [Azure AI FLUX Models ↗](https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/black-forest-labs-flux-1-kontext-pro-and-flux1-1-pro-now-available-in-azure-ai-f/4434659) | +| Supported Operations | [`/images/generations`](#image-generation) | + +## Setup + +### API Key & Base URL + +```python showLineNumbers +# Set your Azure AI API credentials +import os +os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" +os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" # e.g., https://your-endpoint.eastus2.inference.ai.azure.com/ +``` + +Get your API key and endpoint from [Azure AI Studio](https://ai.azure.com/). + +## Supported Models + +| Model Name | Description | Cost per Image | +|------------|-------------|----------------| +| `azure_ai/FLUX-1.1-pro` | Latest FLUX 1.1 Pro model for high-quality image generation | $0.04 | +| `azure_ai/FLUX.1-Kontext-pro` | FLUX 1 Kontext Pro model with enhanced context understanding | $0.04 | + +## Image Generation + +### Usage - LiteLLM Python SDK + + + + +```python showLineNumbers title="Basic Image Generation" +import litellm +import os + +# Set your API credentials +os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" +os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" + +# Generate a single image +response = litellm.image_generation( + model="azure_ai/FLUX.1-Kontext-pro", + prompt="A cute baby sea otter swimming in crystal clear water", + api_base=os.environ["AZURE_AI_API_BASE"], + api_key=os.environ["AZURE_AI_API_KEY"] +) + +print(response.data[0].url) +``` + + + + + +```python showLineNumbers title="FLUX 1.1 Pro Image Generation" +import litellm +import os + +# Set your API credentials +os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" +os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" + +# Generate image with FLUX 1.1 Pro +response = litellm.image_generation( + model="azure_ai/FLUX-1.1-pro", + prompt="A futuristic cityscape at night with neon lights and flying cars", + api_base=os.environ["AZURE_AI_API_BASE"], + api_key=os.environ["AZURE_AI_API_KEY"] +) + +print(response.data[0].url) +``` + + + + + +```python showLineNumbers title="Async Image Generation" +import litellm +import asyncio +import os + +async def generate_image(): + # Set your API credentials + os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" + os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" + + # Generate image asynchronously + response = await litellm.aimage_generation( + model="azure_ai/FLUX.1-Kontext-pro", + prompt="A beautiful sunset over mountains with vibrant colors", + api_base=os.environ["AZURE_AI_API_BASE"], + api_key=os.environ["AZURE_AI_API_KEY"], + n=1, + ) + + print(response.data[0].url) + return response + +# Run the async function +asyncio.run(generate_image()) +``` + + + + + +```python showLineNumbers title="Advanced Image Generation with Parameters" +import litellm +import os + +# Set your API credentials +os.environ["AZURE_AI_API_KEY"] = "your-api-key-here" +os.environ["AZURE_AI_API_BASE"] = "your-azure-ai-endpoint" + +# Generate image with additional parameters +response = litellm.image_generation( + model="azure_ai/FLUX-1.1-pro", + prompt="A majestic dragon soaring over a medieval castle at dawn", + api_base=os.environ["AZURE_AI_API_BASE"], + api_key=os.environ["AZURE_AI_API_KEY"], + n=1, + size="1024x1024", + quality="standard" +) + +for image in response.data: + print(f"Generated image URL: {image.url}") +``` + + + + +### Usage - LiteLLM Proxy Server + +#### 1. Configure your config.yaml + +```yaml showLineNumbers title="Azure AI Image Generation Configuration" +model_list: + - model_name: azure-flux-kontext + litellm_params: + model: azure_ai/FLUX.1-Kontext-pro + api_key: os.environ/AZURE_AI_API_KEY + api_base: os.environ/AZURE_AI_API_BASE + model_info: + mode: image_generation + + - model_name: azure-flux-11-pro + litellm_params: + model: azure_ai/FLUX-1.1-pro + api_key: os.environ/AZURE_AI_API_KEY + api_base: os.environ/AZURE_AI_API_BASE + model_info: + mode: image_generation + +general_settings: + master_key: sk-1234 +``` + +#### 2. Start LiteLLM Proxy Server + +```bash showLineNumbers title="Start LiteLLM Proxy Server" +litellm --config /path/to/config.yaml + +# RUNNING on http://0.0.0.0:4000 +``` + +#### 3. Make requests with OpenAI Python SDK + + + + +```python showLineNumbers title="Azure AI Image Generation via Proxy - OpenAI SDK" +from openai import OpenAI + +# Initialize client with your proxy URL +client = OpenAI( + base_url="http://localhost:4000", # Your proxy URL + api_key="sk-1234" # Your proxy API key +) + +# Generate image with FLUX Kontext Pro +response = client.images.generate( + model="azure-flux-kontext", + prompt="A serene Japanese garden with cherry blossoms and a peaceful pond", + n=1, + size="1024x1024" +) + +print(response.data[0].url) +``` + + + + + +```python showLineNumbers title="Azure AI Image Generation via Proxy - LiteLLM SDK" +import litellm + +# Configure LiteLLM to use your proxy +response = litellm.image_generation( + model="litellm_proxy/azure-flux-11-pro", + prompt="A cyberpunk warrior in a neon-lit alleyway", + api_base="http://localhost:4000", + api_key="sk-1234" +) + +print(response.data[0].url) +``` + + + + + +```bash showLineNumbers title="Azure AI Image Generation via Proxy - cURL" +curl --location 'http://localhost:4000/v1/images/generations' \ +--header 'Content-Type: application/json' \ +--header 'Authorization: Bearer sk-1234' \ +--data '{ + "model": "azure-flux-kontext", + "prompt": "A cozy coffee shop interior with warm lighting and rustic wooden furniture", + "n": 1, + "size": "1024x1024" +}' +``` + + + + +## Supported Parameters + +Azure AI Image Generation supports the following OpenAI-compatible parameters: + +| Parameter | Type | Description | Default | Example | +|-----------|------|-------------|---------|---------| +| `prompt` | string | Text description of the image to generate | Required | `"A sunset over the ocean"` | +| `model` | string | The FLUX model to use for generation | Required | `"azure_ai/FLUX.1-Kontext-pro"` | +| `n` | integer | Number of images to generate (1-4) | `1` | `2` | +| `size` | string | Image dimensions | `"1024x1024"` | `"512x512"`, `"1024x1024"` | +| `api_base` | string | Your Azure AI endpoint URL | Required | `"https://your-endpoint.eastus2.inference.ai.azure.com/"` | +| `api_key` | string | Your Azure AI API key | Required | Environment variable or direct value | + +## Getting Started + +1. Create an account at [Azure AI Studio](https://ai.azure.com/) +2. Deploy a FLUX model in your Azure AI Studio workspace +3. Get your API key and endpoint from the deployment details +4. Set your `AZURE_AI_API_KEY` and `AZURE_AI_API_BASE` environment variables +5. Start generating images using LiteLLM + +## Additional Resources + +- [Azure AI Studio Documentation](https://docs.microsoft.com/en-us/azure/ai-services/) +- [FLUX Models Announcement](https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/black-forest-labs-flux-1-kontext-pro-and-flux1-1-pro-now-available-in-azure-ai-f/4434659) diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js index 419afcd546..f81ecda391 100644 --- a/docs/my-website/sidebars.js +++ b/docs/my-website/sidebars.js @@ -372,7 +372,14 @@ const sidebars = { "providers/azure/azure_embedding", ] }, - "providers/azure_ai", + { + type: "category", + label: "Azure AI", + items: [ + "providers/azure_ai", + "providers/azure_ai_img", + ] + }, { type: "category", label: "Vertex AI", diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.py index 9956a9d314..6c6a09cd73 100644 --- a/litellm/cost_calculator.py +++ b/litellm/cost_calculator.py @@ -32,9 +32,6 @@ from litellm.llms.azure.cost_calculation import ( from litellm.llms.bedrock.cost_calculation import ( cost_per_token as bedrock_cost_per_token, ) -from litellm.llms.bedrock.image.cost_calculator import ( - cost_calculator as bedrock_image_cost_calculator, -) from litellm.llms.databricks.cost_calculator import ( cost_per_token as databricks_cost_per_token, ) @@ -60,9 +57,6 @@ from litellm.llms.vertex_ai.cost_calculator import ( cost_per_token as google_cost_per_token, ) from litellm.llms.vertex_ai.cost_calculator import cost_router as google_cost_router -from litellm.llms.vertex_ai.image_generation.cost_calculator import ( - cost_calculator as vertex_ai_image_cost_calculator, -) from litellm.responses.utils import ResponseAPILoggingUtils from litellm.types.llms.openai import ( HttpxBinaryResponseContent, @@ -768,50 +762,15 @@ def completion_cost( # noqa: PLR0915 ) if CostCalculatorUtils._call_type_has_image_response(call_type): ### IMAGE GENERATION COST CALCULATION ### - if custom_llm_provider == "vertex_ai": - if isinstance(completion_response, ImageResponse): - return vertex_ai_image_cost_calculator( - model=model, - image_response=completion_response, - ) - elif custom_llm_provider == "bedrock": - if isinstance(completion_response, ImageResponse): - return bedrock_image_cost_calculator( - model=model, - size=size, - image_response=completion_response, - optional_params=optional_params, - ) - raise TypeError( - "completion_response must be of type ImageResponse for bedrock image cost calculation" - ) - elif custom_llm_provider == litellm.LlmProviders.RECRAFT.value: - from litellm.llms.recraft.cost_calculator import ( - cost_calculator as recraft_image_cost_calculator, - ) - - return recraft_image_cost_calculator( - model=model, - image_response=completion_response, - ) - elif custom_llm_provider == litellm.LlmProviders.GEMINI.value: - from litellm.llms.gemini.image_generation.cost_calculator import ( - cost_calculator as gemini_image_cost_calculator, - ) - - return gemini_image_cost_calculator( - model=model, - image_response=completion_response, - ) - else: - return default_image_cost_calculator( - model=model, - quality=quality, - custom_llm_provider=custom_llm_provider, - n=n, - size=size, - optional_params=optional_params, - ) + return CostCalculatorUtils.route_image_generation_cost_calculator( + model=model, + custom_llm_provider=custom_llm_provider, + completion_response=completion_response, + quality=quality, + n=n, + size=size, + optional_params=optional_params, + ) elif ( call_type == CallTypes.speech.value or call_type == CallTypes.aspeech.value diff --git a/litellm/images/main.py b/litellm/images/main.py index 9ce83ccc18..ca14fabd1f 100644 --- a/litellm/images/main.py +++ b/litellm/images/main.py @@ -335,6 +335,38 @@ def image_generation( # noqa: PLR0915 headers=headers, litellm_params=litellm_params_dict, ) + elif custom_llm_provider == "azure_ai": + from litellm.llms.azure_ai.common_utils import AzureFoundryModelInfo + api_base = AzureFoundryModelInfo.get_api_base(api_base) + api_key = AzureFoundryModelInfo.get_api_key(api_key) + if extra_headers is not None: + optional_params["extra_headers"] = extra_headers + + default_headers = { + "Content-Type": "application/json", + "api-key": api_key, + } + for k, v in default_headers.items(): + if k not in headers: + headers[k] = v + + model_response = azure_chat_completions.image_generation( + model=model, + prompt=prompt, + timeout=timeout, + api_key=api_key, + api_base=api_base, + azure_ad_token=None, + azure_ad_token_provider=azure_ad_token_provider, + logging_obj=litellm_logging_obj, + optional_params=optional_params, + model_response=model_response, + api_version=api_version, + aimg_generation=aimg_generation, + client=client, + headers=headers, + litellm_params=litellm_params_dict, + ) elif ( custom_llm_provider == "openai" or custom_llm_provider in litellm.openai_compatible_providers diff --git a/litellm/litellm_core_utils/llm_cost_calc/utils.py b/litellm/litellm_core_utils/llm_cost_calc/utils.py index 737e3f7f98..4b6cffd06c 100644 --- a/litellm/litellm_core_utils/llm_cost_calc/utils.py +++ b/litellm/litellm_core_utils/llm_cost_calc/utils.py @@ -1,11 +1,17 @@ # What is this? ## Helper utilities for cost_per_token() -from typing import Literal, Optional, Tuple, cast +from typing import Any, Literal, Optional, Tuple, cast import litellm from litellm._logging import verbose_logger -from litellm.types.utils import CallTypes, ModelInfo, PassthroughCallTypes, Usage +from litellm.types.utils import ( + CallTypes, + ImageResponse, + ModelInfo, + PassthroughCallTypes, + Usage, +) from litellm.utils import get_model_info @@ -377,3 +383,84 @@ class CostCalculatorUtils: ]: return True return False + + @staticmethod + def route_image_generation_cost_calculator( + model: str, + completion_response: Any, + custom_llm_provider: Optional[str] = None, + quality: Optional[str] = None, + n: Optional[int] = None, + size: Optional[str] = None, + optional_params: Optional[dict] = None, + ) -> float: + """ + Route the image generation cost calculator based on the custom_llm_provider + """ + from litellm.cost_calculator import default_image_cost_calculator + from litellm.llms.azure_ai.image_generation.cost_calculator import ( + cost_calculator as azure_ai_image_cost_calculator, + ) + from litellm.llms.bedrock.image.cost_calculator import ( + cost_calculator as bedrock_image_cost_calculator, + ) + from litellm.llms.gemini.image_generation.cost_calculator import ( + cost_calculator as gemini_image_cost_calculator, + ) + from litellm.llms.recraft.cost_calculator import ( + cost_calculator as recraft_image_cost_calculator, + ) + from litellm.llms.vertex_ai.image_generation.cost_calculator import ( + cost_calculator as vertex_ai_image_cost_calculator, + ) + + if custom_llm_provider == litellm.LlmProviders.VERTEX_AI.value: + if isinstance(completion_response, ImageResponse): + return vertex_ai_image_cost_calculator( + model=model, + image_response=completion_response, + ) + elif custom_llm_provider == litellm.LlmProviders.BEDROCK.value: + if isinstance(completion_response, ImageResponse): + return bedrock_image_cost_calculator( + model=model, + size=size, + image_response=completion_response, + optional_params=optional_params, + ) + raise TypeError( + "completion_response must be of type ImageResponse for bedrock image cost calculation" + ) + elif custom_llm_provider == litellm.LlmProviders.RECRAFT.value: + from litellm.llms.recraft.cost_calculator import ( + cost_calculator as recraft_image_cost_calculator, + ) + + return recraft_image_cost_calculator( + model=model, + image_response=completion_response, + ) + elif custom_llm_provider == litellm.LlmProviders.GEMINI.value: + from litellm.llms.gemini.image_generation.cost_calculator import ( + cost_calculator as gemini_image_cost_calculator, + ) + + return gemini_image_cost_calculator( + model=model, + image_response=completion_response, + ) + elif custom_llm_provider == litellm.LlmProviders.AZURE_AI.value: + return azure_ai_image_cost_calculator( + model=model, + image_response=completion_response, + ) + else: + return default_image_cost_calculator( + model=model, + quality=quality, + custom_llm_provider=custom_llm_provider, + n=n, + size=size, + optional_params=optional_params, + ) + return 0.0 diff --git a/litellm/llms/azure_ai/common_utils.py b/litellm/llms/azure_ai/common_utils.py new file mode 100644 index 0000000000..dcc9335e42 --- /dev/null +++ b/litellm/llms/azure_ai/common_utils.py @@ -0,0 +1,56 @@ +from typing import List, Optional + +import litellm +from litellm.llms.base_llm.base_utils import BaseLLMModelInfo +from litellm.secret_managers.main import get_secret_str +from litellm.types.llms.openai import AllMessageValues + + +class AzureFoundryModelInfo(BaseLLMModelInfo): + @staticmethod + def get_api_base(api_base: Optional[str] = None) -> Optional[str]: + return ( + api_base + or litellm.api_base + or get_secret_str("AZURE_AI_API_BASE") + ) + + @staticmethod + def get_api_key(api_key: Optional[str] = None) -> Optional[str]: + return ( + api_key + or litellm.api_key + or litellm.openai_key + or get_secret_str("AZURE_AI_API_KEY") + ) + + @property + def api_version(self, api_version: Optional[str] = None) -> Optional[str]: + api_version = ( + api_version + or litellm.api_version + or get_secret_str("AZURE_API_VERSION") + ) + return api_version + + ######################################################### + # Not implemented methods + ######################################################### + + + @staticmethod + def get_base_model(model: str) -> Optional[str]: + raise NotImplementedError("Azure Foundry does not support base model") + + def validate_environment( + self, + headers: dict, + model: str, + messages: List[AllMessageValues], + optional_params: dict, + litellm_params: dict, + api_key: Optional[str] = None, + api_base: Optional[str] = None, + ) -> dict: + """Azure Foundry sends api key in query params""" + raise NotImplementedError("Azure Foundry does not support environment validation") diff --git a/litellm/llms/azure_ai/image_generation/__init__.py b/litellm/llms/azure_ai/image_generation/__init__.py new file mode 100644 index 0000000000..cebab3de16 --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/__init__.py @@ -0,0 +1,33 @@ +from litellm._logging import verbose_logger +from litellm.llms.base_llm.image_generation.transformation import ( + BaseImageGenerationConfig, +) + +from .dall_e_2_transformation import AzureFoundryDallE2ImageGenerationConfig +from .dall_e_3_transformation import AzureFoundryDallE3ImageGenerationConfig +from .flux_transformation import AzureFoundryFluxImageGenerationConfig +from .gpt_transformation import AzureFoundryGPTImageGenerationConfig + +__all__ = [ + "AzureFoundryFluxImageGenerationConfig", + "AzureFoundryGPTImageGenerationConfig", + "AzureFoundryDallE2ImageGenerationConfig", + "AzureFoundryDallE3ImageGenerationConfig", +] + + +def get_azure_ai_image_generation_config(model: str) -> BaseImageGenerationConfig: + model = model.lower() + model = model.replace("-", "") + model = model.replace("_", "") + if model == "" or "dalle2" in model: # empty model is dall-e-2 + return AzureFoundryDallE2ImageGenerationConfig() + elif "dalle3" in model: + return AzureFoundryDallE3ImageGenerationConfig() + elif "flux" in model: + return AzureFoundryFluxImageGenerationConfig() + else: + verbose_logger.debug( + f"Using AzureGPTImageGenerationConfig for model: {model}. This follows the gpt-image-1 model format." + ) + return AzureFoundryGPTImageGenerationConfig() diff --git a/litellm/llms/azure_ai/image_generation/cost_calculator.py b/litellm/llms/azure_ai/image_generation/cost_calculator.py new file mode 100644 index 0000000000..2fc7c554a3 --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/cost_calculator.py @@ -0,0 +1,25 @@ +from typing import Any + +import litellm +from litellm.types.utils import ImageResponse + + +def cost_calculator( + model: str, + image_response: Any, +) -> float: + """ + Recraft image generation cost calculator + """ + _model_info = litellm.get_model_info( + model=model, + custom_llm_provider=litellm.LlmProviders.AZURE_AI.value, + ) + output_cost_per_image: float = _model_info.get("output_cost_per_image") or 0.0 + num_images: int = 0 + if isinstance(image_response, ImageResponse): + if image_response.data: + num_images = len(image_response.data) + return output_cost_per_image * num_images + else: + raise ValueError(f"image_response must be of type ImageResponse got type={type(image_response)}") diff --git a/litellm/llms/azure_ai/image_generation/dall_e_2_transformation.py b/litellm/llms/azure_ai/image_generation/dall_e_2_transformation.py new file mode 100644 index 0000000000..1ef93366f7 --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/dall_e_2_transformation.py @@ -0,0 +1,9 @@ +from litellm.llms.openai.image_generation import DallE2ImageGenerationConfig + + +class AzureFoundryDallE2ImageGenerationConfig(DallE2ImageGenerationConfig): + """ + Azure dall-e-2 image generation config + """ + + pass diff --git a/litellm/llms/azure_ai/image_generation/dall_e_3_transformation.py b/litellm/llms/azure_ai/image_generation/dall_e_3_transformation.py new file mode 100644 index 0000000000..4688a5c3ca --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/dall_e_3_transformation.py @@ -0,0 +1,9 @@ +from litellm.llms.openai.image_generation import DallE3ImageGenerationConfig + + +class AzureFoundryDallE3ImageGenerationConfig(DallE3ImageGenerationConfig): + """ + Azure dall-e-3 image generation config + """ + + pass diff --git a/litellm/llms/azure_ai/image_generation/flux_transformation.py b/litellm/llms/azure_ai/image_generation/flux_transformation.py new file mode 100644 index 0000000000..5325f32ef6 --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/flux_transformation.py @@ -0,0 +1,14 @@ +from litellm.llms.openai.image_generation import GPTImageGenerationConfig + + +class AzureFoundryFluxImageGenerationConfig(GPTImageGenerationConfig): + """ + Azure Foundry flux image generation config + + From manual testing it follows the gpt-image-1 image generation config + + (Azure Foundry does not have any docs on supported params at the time of writing) + + From our test suite - following GPTImageGenerationConfig is working for this model + """ + pass diff --git a/litellm/llms/azure_ai/image_generation/gpt_transformation.py b/litellm/llms/azure_ai/image_generation/gpt_transformation.py new file mode 100644 index 0000000000..3eead30746 --- /dev/null +++ b/litellm/llms/azure_ai/image_generation/gpt_transformation.py @@ -0,0 +1,9 @@ +from litellm.llms.openai.image_generation import GPTImageGenerationConfig + + +class AzureFoundryGPTImageGenerationConfig(GPTImageGenerationConfig): + """ + Azure gpt-image-1 image generation config + """ + + pass diff --git a/litellm/main.py b/litellm/main.py index 339d9e1440..4166e60651 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -1592,18 +1592,10 @@ def completion( # type: ignore # noqa: PLR0915 raise e elif custom_llm_provider == "azure_ai": - api_base = ( - api_base # for deepinfra/perplexity/anyscale/groq/friendliai we check in get_llm_provider and pass in the api base from there - or litellm.api_base - or get_secret("AZURE_AI_API_BASE") - ) + from litellm.llms.azure_ai.common_utils import AzureFoundryModelInfo + api_base = AzureFoundryModelInfo.get_api_base(api_base) # set API KEY - api_key = ( - api_key - or litellm.api_key # for deepinfra/perplexity/anyscale/friendliai we check in get_llm_provider and pass in the api key from there - or litellm.openai_key - or get_secret("AZURE_AI_API_KEY") - ) + api_key = AzureFoundryModelInfo.get_api_key(api_key) headers = headers or litellm.headers diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index b0d8245136..4e269052e5 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -4790,6 +4790,24 @@ ], "source": "https://azuremarketplace.microsoft.com/pt-br/marketplace/apps/cohere.cohere-embed-4-offer?tab=PlansAndPrice" }, + "azure_ai/FLUX-1.1-pro": { + "output_cost_per_image": 0.04, + "litellm_provider": "azure_ai", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/black-forest-labs-flux-1-kontext-pro-and-flux1-1-pro-now-available-in-azure-ai-f/4434659" + }, + "azure_ai/FLUX.1-Kontext-pro": { + "output_cost_per_image": 0.04, + "litellm_provider": "azure_ai", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://azuremarketplace.microsoft.com/pt-br/marketplace/apps/cohere.cohere-embed-4-offer?tab=PlansAndPrice" + }, "babbage-002": { "max_tokens": 16384, "max_input_tokens": 16384, diff --git a/litellm/utils.py b/litellm/utils.py index fb4f1662a7..b23b995b28 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -7280,6 +7280,12 @@ class ProviderConfigManager: ) return get_azure_image_generation_config(model) + elif LlmProviders.AZURE_AI == provider: + from litellm.llms.azure_ai.image_generation import ( + get_azure_ai_image_generation_config, + ) + + return get_azure_ai_image_generation_config(model) elif LlmProviders.XINFERENCE == provider: from litellm.llms.xinference.image_generation import ( get_xinference_image_generation_config, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index b0d8245136..4e269052e5 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -4790,6 +4790,24 @@ ], "source": "https://azuremarketplace.microsoft.com/pt-br/marketplace/apps/cohere.cohere-embed-4-offer?tab=PlansAndPrice" }, + "azure_ai/FLUX-1.1-pro": { + "output_cost_per_image": 0.04, + "litellm_provider": "azure_ai", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://techcommunity.microsoft.com/blog/azure-ai-foundry-blog/black-forest-labs-flux-1-kontext-pro-and-flux1-1-pro-now-available-in-azure-ai-f/4434659" + }, + "azure_ai/FLUX.1-Kontext-pro": { + "output_cost_per_image": 0.04, + "litellm_provider": "azure_ai", + "mode": "image_generation", + "supported_endpoints": [ + "/v1/images/generations" + ], + "source": "https://azuremarketplace.microsoft.com/pt-br/marketplace/apps/cohere.cohere-embed-4-offer?tab=PlansAndPrice" + }, "babbage-002": { "max_tokens": 16384, "max_input_tokens": 16384, diff --git a/tests/image_gen_tests/test_image_generation.py b/tests/image_gen_tests/test_image_generation.py index c34fd0b5e8..0e5f1d79fa 100644 --- a/tests/image_gen_tests/test_image_generation.py +++ b/tests/image_gen_tests/test_image_generation.py @@ -187,6 +187,19 @@ class TestAzureOpenAIDalle3(BaseImageGenTest): } }, } + + + +class TestAzureFoundryFlux(BaseImageGenTest): + def get_base_image_generation_call_args(self) -> dict: + litellm.set_verbose = True + return { + "model": "azure_ai/FLUX.1-Kontext-pro", + "api_base": os.getenv("AZURE_FLUX_API_BASE"), + "api_key": os.getenv("AZURE_GPT5_API_KEY"), + "n": 1, + "quality": "standard", + } @pytest.mark.flaky(retries=3, delay=1)