diff --git a/litellm/llms/sap/chat/transformation.py b/litellm/llms/sap/chat/transformation.py index 9d0fc5b57c0..661179e5312 100755 --- a/litellm/llms/sap/chat/transformation.py +++ b/litellm/llms/sap/chat/transformation.py @@ -421,6 +421,12 @@ class GenAIHubOrchestrationConfig(OpenAIGPTConfig): return _normalize_choice_fn(choice) def _strip_markdown_json(self, response: ModelResponse) -> ModelResponse: + """Strip markdown code block wrapper from JSON content if present. + + SAP GenAI Hub with Anthropic models sometimes returns JSON wrapped in + markdown code blocks (```json ... ```) depending on prompt phrasing. + This method strips that wrapper to ensure consistent JSON output. + """ import re for choice in response.choices or []: