Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(responses): omit empty JSON body on DELETE response API requests

mateo-berri8bdc46ea7415
diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py
index a34b73b5313..19939e6d1ea 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(