An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
Retry the entire /responses request with exponential backoff and jitter whenever the stream times out, is truncated, or emits an error event; never treat the partial stream as a completed response.
Azure Responses streaming can begin with HTTP 200 and later fail through an in-stream error event. Microsoft explicitly recommends stopping or restarting the stream in that case.^1^ The errors shown are therefore retryable failures, not ordinary HTTP 400 request-validation errors.
Implement whole-request retries
Use a new request for every attempt and discard any partial output from the failed attempt. Microsoft’s Python SDK already retries connection errors, timeouts, HTTP 408/409/429, and 5xx responses twice; max_retries changes that behavior.^2^
import os, random, time
from openai import OpenAI
client = OpenAI(
base_url=os.environ["AZURE_OPENAI_ENDPOINT"].rstrip("/") + "/openai/v1/",
api_key=os.environ["AZURE_OPENAI_API_KEY"],
timeout=180.0,
max_retries=0, # outer loop controls retries
)
for attempt in range(4):
try:
response = client.responses.create(
model=os.environ["AZURE_OPENAI_DEPLOYMENT"],
input="Your prompt",
)
print(response.output_text)
break
except Exception:
if attempt == 3:
raise
time.sleep(min(2 ** attempt + random.random(), 15))
For streaming, wrap creation and complete consumption of the iterator in the retry block. Buffer output per attempt and publish it only after receiving the normal terminal/completion event. This avoids duplicated or incomplete output when a retry starts.
Do not stack aggressive retries in both LiteLLM and the application. Choose one controlling layer, cap the attempts, and add jitter to prevent synchronized retry bursts.
Isolate Azure OpenAI from LiteLLM
The messages identify failures from different layers:
-
TransferEncodingError: Not enough data to satisfy transfer length headermeans the HTTP body ended before its declared transfer length was received. -
MidStreamFallbackErrormeans failure occurred after streaming had started. -
ping timeoutandlitellm.Timeoutindicate transport or request-lifetime timeouts.
No published evidence establishes one specific October 20, 2026 Azure incident for this exact combination. Run these tests with the same prompt and deployment:
- LiteLLM with
stream=false. - Direct Azure OpenAI SDK with
stream=false, bypassing LiteLLM. - Direct Azure OpenAI SDK with streaming enabled.
- LiteLLM streaming.
Interpret the result:
- Direct Azure calls also fail: proceed as an Azure service/deployment issue.
- Only LiteLLM streaming fails: inspect the LiteLLM proxy, its HTTP client, ingress/load balancer, and version.
- Only long requests fail: raise the end-to-end timeout and reduce output size or reasoning duration.
- Non-streaming succeeds consistently: use it temporarily while diagnosing stream handling.
This separation matters because LiteLLM documents provider-side and gateway-side failures independently.^3^ LiteLLM also has related stream-handling reports involving truncated upstream bodies and incomplete Azure/OpenAI streams, although neither proves this exact Azure incident.^4^^5^
LiteLLM and proxy checks
- Record the installed LiteLLM version and compare it with the current stable release.
- If the problem began after an upgrade, test the previous known-good version in staging.
- If running LiteLLM
1.105.0, verify whetherGZipBufferedResponseMiddlewareis involved. A reported regression in that version delays streamed response headers until the first chunk or keepalive ping.^6^ - Ensure every intermediary—API Management, application gateway, ingress controller, reverse proxy, or firewall—has an idle/read timeout longer than the maximum model request.
- Reuse HTTP clients rather than creating one per call, and check the hosting service for connection/SNAT exhaustion if failures rise with concurrency.
If direct Azure requests fail too
Azure classifies 500/503 responses as transient service or backend-overload errors and recommends exponential backoff. If they persist beyond a few minutes, check Azure Service Health and open a support request.^7^
Include:
- UTC timestamps
- Azure region and deployment/model version
-
/responses, streaming setting, and timeout values - all
x-client-request-idvalues shown above - Azure response/request IDs, if available
- whether direct non-LiteLLM calls reproduce the failure
- frequency, concurrency, and approximate request/output sizes
- a sanitized minimal reproduction
A temporary deployment in another supported region or a fallback deployment can keep the workload running while the affected path is investigated. Do not send API keys, prompts containing sensitive data, or tenant identifiers in a public Q&A post.
References
- Use the Azure OpenAI Responses API
- Azure OpenAI SDK language support (programming-language-python)
- Diagnosing Errors - Provider vs Gateway | liteLLM
- [Bug]: /v1/messages streaming: transport drop before first ... - GitHub
- #40260 [Bug]: OpenAI/Azure clean stream EOF without finish_reason is reported as successful completion
- #46659 [Bug]: v1.105.0 GZipBufferedResponseMiddleware withholds response headers of streamed (SSE) responses until the first chunk; MCP tools/call streams start only at the 15s ping
- Troubleshoot common HTTP errors for Azure OpenAI