diff --git a/litellm/llms/openrouter/chat/transformation.py b/litellm/llms/openrouter/chat/transformation.py index 4b95ec87cf..ab4d3c52b9 100644 --- a/litellm/llms/openrouter/chat/transformation.py +++ b/litellm/llms/openrouter/chat/transformation.py @@ -84,5 +84,11 @@ class OpenRouterChatCompletionStreamingHandler(BaseModelResponseIterator): model=chunk["model"], choices=new_choices, ) + except KeyError as e: + raise OpenRouterException( + message=f"KeyError: {e}, Got unexpected response from OpenRouter: {chunk}", + status_code=400, + headers={"Content-Type": "application/json"}, + ) except Exception as e: raise e