FLUX.1-Kontext-pro model and Azure AI Foundry.

GS 410 Reputation points
2025-08-05T23:46:10.6833333+00:00

I deployed the FLUX.1-Kontext-pro model to Azure AI Foundry.

While the image generation works great, the editing endpoint does not seem to work.

Here is the error that is returned:

Failed to generate image: No model specified in request. Please provide a model name in the request body or as a x-ms-model-mesh-model-name header. Trace ID : 6199947b-82fa-4314-98db-03d314a3afc1

I used the same code provided in the playground. Trying to edit in the playground gives the same error message.

Does the edit endpoint work at all ?

# Initialize the DefaultAzureCredential to be used for Entra ID authentication.
# If you receive a `PermissionDenied` error, be sure that you run `az login` in your terminal
# and that you have the correct permissions to access the resource.
# Learn more about necessary permissions:  https://aka.ms/azure-openai-roles
credential = DefaultAzureCredential()
token_response = credential.get_token("https://cognitiveservices.azure.com/.default")

base_path = f'openai/deployments/{deployment}/images'
params = f'?api-version={api_version}'

generation_url = f"https://xxxxxx.cognitiveservices.azure.com/{base_path}/generations{params}"
generation_body = {
  "prompt": "create a image of cats on a playground",
  "n": 1,
  "size": "1024x1024",
  "output_format": "png"
}
generation_response = requests.post(
  generation_url,
  headers={
    'Authorization': 'Bearer ' + token_response.token,
    'Content-Type': 'application/json',
  },
  json=generation_body
).json()
save_response(generation_response, "generated_image")

# In addition to generating images, you can edit them.
edit_url = f"{endpoint}{base_path}/edits{params}"
edit_body = {
  "prompt": "add dogs to the playground",
  "n": 1,
  "size": "1024x1024"
}
files = {
  "image": ("generated_image.png", open("generated_image.png", "rb"), "image/png"),
}
edit_response = requests.post(
  edit_url,
  headers={'Authorization': 'Bearer ' + token_response.token},
  data=edit_body,
  files=files
).json()
save_response(edit_response, "edited_image")
Foundry Tools
Foundry Tools

Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform

0 comments No comments

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

  2. Pavankumar Purilla 11,355 Reputation points Moderator
    2025-08-06T10:53:17.0466667+00:00

    Hi Siry, Gaetan,
    The image editing endpoint is not currently supported for the FLUX.1-Kontext-pro model in Azure AI Foundry. While the image generation functionality works as expected, any attempt to use the /edits endpoint results in the error “No model specified in request,” because the service does not expose a valid edit route for this model. This is a known limitation, and the same behavior can be observed in the Azure AI Foundry playground. At this time, FLUX.1-Kontext-pro can only be used for image generation. For image editing or inpainting capabilities, you will need to use a model that supports editing, such as DALL·E 3, or handle editing through an external image processing library. There is currently no announced ETA for edit support with FLUX.1-Kontext-pro.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.