From 8bdc46ea74155081c4d043a90f171de2c0c9e9fa Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 30 Apr 2026 17:55:27 -0700 Subject: [PATCH] fix(responses): omit empty JSON body on DELETE response API requests Azure OpenAI's responses-API DELETE endpoint rejects requests that carry a JSON body with: "Unexpected body with size 2. This API method does not accept a request body.". The default LiteLLMAiohttpTransport silently elides empty-dict bodies on DELETE so this was masked, but the pure-httpx transport (used when DISABLE_AIOHTTP_TRANSPORT=True or under vcrpy/respx patching) sends literal '{}' (2 bytes), which Azure rejects. Only attach json= when the provider's transform actually returned a non-empty dict; otherwise issue a bodyless DELETE. --- litellm/llms/custom_httpx/llm_http_handler.py | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py index a34b73b531..19939e6d1e 100644 --- a/litellm/llms/custom_httpx/llm_http_handler.py +++ b/litellm/llms/custom_httpx/llm_http_handler.py @@ -2536,9 +2536,16 @@ class BaseLLMHTTPHandler: ) try: - response = await async_httpx_client.delete( - url=url, headers=headers, json=data, timeout=timeout - ) + # Only send a JSON body when the provider supplied request data; + # some providers (e.g. Azure OpenAI) reject DELETE with a body. + delete_kwargs: Dict[str, Any] = { + "url": url, + "headers": headers, + "timeout": timeout, + } + if data: + delete_kwargs["json"] = data + response = await async_httpx_client.delete(**delete_kwargs) except Exception as e: raise self._handle_error( @@ -2620,9 +2627,16 @@ class BaseLLMHTTPHandler: ) try: - response = sync_httpx_client.delete( - url=url, headers=headers, json=data, timeout=timeout - ) + # Only send a JSON body when the provider supplied request data; + # some providers (e.g. Azure OpenAI) reject DELETE with a body. + delete_kwargs: Dict[str, Any] = { + "url": url, + "headers": headers, + "timeout": timeout, + } + if data: + delete_kwargs["json"] = data + response = sync_httpx_client.delete(**delete_kwargs) except Exception as e: raise self._handle_error(