- Deploy FLUX models in Microsoft Foundry
- Authenticate by using Microsoft Entra ID or API keys
- Generate images by using the BFL provider-specific API or the Image API
- Edit images by combining text prompts with reference images
- Choose the right FLUX model for your use case
To learn more about each model, see Available FLUX models.
Prerequisites
- An Azure subscription with a valid payment method. If you don’t have an Azure subscription, create a paid Azure account.
- Access to Microsoft Foundry with appropriate permissions to create and manage resources.
- A Microsoft Foundry project in any region, since FLUX models are available for global standard deployment in all regions.
- Cognitive Services Contributor role on the Foundry resource to deploy models. For more information, see Azure RBAC roles.
Deploy FLUX models
You can deploy FLUX models through global standard deployment. For a full list of supported regions, see Region availability for Foundry Models sold by Azure. To deploy a FLUX model, follow the instructions in Deploy Microsoft Foundry Models in the Foundry portal. After deployment, use the Foundry playground to interactively test the model with text prompts.Support for multiple reference images is available for FLUX.2 [pro] and FLUX.2 [flex] through the API, but not in the playground.
Overview of image generation with FLUX models
After you deploy a FLUX model, use either the BFL provider-specific API or the Image API to generate images:- BFL provider-specific API: Supports all FLUX models and provides access to additional parameters such as
guidance,steps,seed,aspect_ratio,safety_tolerance, andoutput_format. Use this route for fine-grained control over generation. - Image API: An OpenAI-compatible endpoint available for
FLUX.1-Kontext-proandFLUX-1.1-pro. Use this route if your application already uses the Azure OpenAI images API.
Use the BFL API with FLUX models
The BFL provider-specific API endpoint has the following form:<model-path> in the endpoint as follows:
The model ID and
<model-path> aren’t identical. Be sure to use the model path in the endpoint URL.Image generation (text to image)
The following examples use FLUX.2 [pro] to generate an image from a text prompt. For a FLUX.2 [flex]-specific example with its additional parameters (guidance, steps), see FLUX.2 [flex].
- Python
- REST API
Use API key authentication
-
Install the
requestslibrary: -
Set environment variables:
-
Run the following code:
Expected output: A JSON response containing a URL or base64-encoded image data for the generated image. Reference: BFL FLUX.2 text-to-image API
Use Microsoft Entra ID authentication
To use Microsoft Entra ID instead of an API key, replace theAuthorization header value with a bearer token obtained using the DefaultAzureCredential:-
Install the Azure Identity library:
-
Update the authorization header in the previous code:
Reference: DefaultAzureCredential
Image editing with reference images (FLUX.2 models)
FLUX.2 [pro] and FLUX.2 [flex] support multi-reference image editing, which lets you pass multiple base64-encoded images alongside a text prompt. The model applies stylistic or content changes across all reference images.- FLUX.2 [pro]: Up to eight reference images
- FLUX.2 [flex]: Up to 10 reference images
- Python
- REST API
Use the Image API with FLUX models
FLUX.1-Kontext-pro and FLUX-1.1-pro are also available through the Image API, which uses the same endpoint format as the Azure OpenAI images API. The Image API endpoint has the following form:
FLUX.1-Kontext-pro also supports:
Image generation (text to image)
- Python
- REST API
-
Install the OpenAI library:
-
Set environment variables:
-
Run the following code:
Expected output: A URL to the generated image. Reference: OpenAI Python client, Image generations - Create
Image editing with the Image API (FLUX.1 Kontext [pro])
FLUX.1-Kontext-pro also supports the images/edits endpoint, which lets you pass a reference image alongside a text prompt for in-context editing.
- Python
- REST API
Available FLUX models
See the Black Forest Labs model collection in the Foundry portal for available models. For more details about model capabilities, see Foundry Models sold by Azure.FLUX.2 [flex]
FLUX.2 [flex] (FLUX.2-flex) offers fine-grained control with more stable throughput — throughput degrades more gracefully as image size increases. It’s best suited for text-heavy layouts and images that require text overlay or fine detail preservation. It accepts text and image input (32,000 tokens and up to 10 images) and outputs one image in PNG or JPG format. Maximum output resolution is 4 MP.
Additional parameters (BFL provider API only):
The following example shows a FLUX.2 [flex]-specific request for image generation using the
guidance and steps parameters:
FLUX.2 [pro]
FLUX.2 [pro] (FLUX.2-pro) delivers state-of-the-art image quality at maximum speed, making it the best choice for production workloads at scale. Note that it exhibits higher response times compared to FLUX.1 Kontext [pro] and FLUX.2 [flex], and throughput decreases at higher resolutions. It accepts text and image input (32,000 tokens and up to eight images) and outputs one image in PNG or JPG format. Maximum output resolution is 4 MP.
The BFL provider API supports all parameters for FLUX.2 [pro], including guidance, steps, seed, aspect_ratio, safety_tolerance, and output_format.
FLUX.1 Kontext [pro]
FLUX.1 Kontext [pro] (FLUX.1-Kontext-pro) specializes in in-context generation and editing with strong character consistency across edits. It accepts text and image input (5,000 tokens and 1 image) and outputs one image in PNG or JPG format. Maximum output resolution is 1 MP.
FLUX.1 Kontext [pro] is available through both the BFL provider API and the Image API (images/generations and images/edits).
Additional parameters (BFL provider API only): seed, aspect_ratio, input_image, prompt_unsampling, safety_tolerance, output_format.
FLUX1.1 [pro]
FLUX1.1 [pro] (FLUX-1.1-pro) delivers fast text-to-image generation with strong prompt adherence, competitive pricing, and scalable generation. It accepts text input (5,000 tokens) and outputs one image in PNG or JPG format. Maximum output resolution is 1.6 MP.
FLUX1.1 [pro] is available through both the BFL provider API and the Image API (images/generations).
Additional parameters (BFL provider API only): width, height, prompt_unsampling, seed, safety_tolerance, output_format.
API quotas and limits
FLUX models in Foundry have the following rate limits measured in Requests Per Minute (RPM). The tier available to you depends on your subscription and deployment configuration.
To request a quota increase, submit the quota increase request form. Requests are processed in the order they’re received, and priority goes to customers who actively use their existing quota allocation.
Responsible AI considerations
When using FLUX models in Foundry, consider these responsible AI practices:- Configure AI content safety during model inference, because Foundry doesn’t provide built-in content filtering for FLUX models at deployment time.
- Ensure your use of generated images complies with Black Forest Labs’ terms of service and applicable copyright and intellectual property laws.
- Be transparent about AI-generated content when sharing or publishing images.
- Avoid generating content that could be harmful, misleading, or in violation of privacy.