Hello Angel Sevillano,
Welcome to Microsoft Q&A and Thank you for sharing the details and code snippet.
Since the same code was working last week and now returns a 408 Timeout error only for images larger than ~170 KB, this likely points to a service-side processing or latency issue rather than a problem in your implementation.
Below are the most relevant things to check and try:
Image Size and Base64 Payload
When sending images as Base64:
- Base64 increases the payload size by ~33%.
A 170 KB image becomes ~225 KB in the request body.
Larger images significantly increase preprocessing time for diffusion-based models like FLUX.2-pro.
If larger images now time out, this could indicate:
Increased backend latency
Stricter request processing limits
Higher regional load
Recommendation:
Resize images before encoding (e.g., max 1024x1024).
Compress images (quality=85, optimize=True) before converting to Base64.
Test with smaller output resolution (e.g., 768x768) to confirm if this is compute-related.
If smaller images work consistently, this confirms a processing timeout rather than a code issue.
Increase Client Request Timeout
Your current requests.post() call does not specify a timeout. While the service may still enforce limits, increasing the client timeout ensures your client isn’t closing early.
Example:
response = requests.post(
FLUX2_PRO_ENDPOINT,
headers=get_headers(),
json=data,
timeout=120 # 2 minutes
)
You can test with 120–180 seconds.
Deployment Request Timeout Setting
If this model is deployed through Foundry with configurable deployment settings, verify whether a request timeout is set.
You can increase:
request_settings:
request_timeout_ms: 300000
(5 minutes)
If the timeout is happening at the deployment layer, this may resolve it.
Service Health Check
Since this worked last week:
Check Azure Service Health for any incidents affecting:
Azure AI Foundry
BlackForestLabs provider
Your specific region
Latency increases due to regional capacity changes can cause previously working workloads to start timing out.
Quota or Throttling
Ensure your subscription has not:
Reached quota limits
Hit throttling thresholds
Experienced reduced regional capacity
Even without explicit 429 errors, backend capacity pressure can manifest as timeouts.
Monitor Performance
Use:
- Azure Monitor
- Diagnostic logs
- Correlation ID from failed requests
Likely Root Cause
Given that:
The same code worked previously
Smaller images still work
Only larger payloads fail
This strongly suggests either:
Increased model latency under load
Reduced processing timeout window
Regional capacity change
Backend behavior change in preview API
Since you are using a preview API version, changes in limits or backend behavior can occur without explicit announcements.
Suggested Diagnostic Test
Try Same image, Resize to 512x512, Keep same prompt.
If it succeeds → confirms compute timeout rather than payload rejection.
If resizing and timeout adjustments do not resolve the issue, this may require escalation to check backend latency or capacity for FLUX.2-pro in your region.
Please refer this
I Hope this helps. Do let me know if you have any further queries.
Thank you!