From 781c6224d9902c6b8338ea6889061c0ba3a628d2 Mon Sep 17 00:00:00 2001 From: Hemang Date: Thu, 20 Mar 2025 10:54:25 +0100 Subject: [PATCH] Anthropic with stream=False complains about content-length not matching with the response size. --- gateway/routes/anthropic.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gateway/routes/anthropic.py b/gateway/routes/anthropic.py index c6716a4..40838e4 100644 --- a/gateway/routes/anthropic.py +++ b/gateway/routes/anthropic.py @@ -140,11 +140,13 @@ async def handle_non_streaming_response( # Don't block on the response from explorer if context.dataset_name: asyncio.create_task(push_to_explorer(context, json_response)) + updated_headers = response.headers.copy() + updated_headers.pop("Content-Length", None) return Response( content=json.dumps(json_response), status_code=response.status_code, media_type="application/json", - headers=dict(response.headers), + headers=dict(updated_headers), )