{"record":{"id":"bae12149f9646f11","repo":"BerriAI/litellm","slug":"str-e-bae121","errorCode":null,"errorMessage":"str(e)","messagePattern":"str\\(e\\)","errorType":"exception","errorClass":"OobaboogaError","httpStatus":null,"severity":"error","filePath":"litellm/llms/oobabooga/chat/transformation.py","lineNumber":66,"sourceCode":"            original_response=raw_response.text,\n            additional_args={\"complete_input_dict\": request_data},\n        )\n\n        ## RESPONSE OBJECT\n        try:\n            completion_response: Final = raw_response.json()\n        except Exception:\n            raise OobaboogaError(message=raw_response.text, status_code=raw_response.status_code)\n        if \"error\" in completion_response:\n            raise OobaboogaError(\n                message=completion_response[\"error\"],\n                status_code=raw_response.status_code,\n            )\n        else:\n            try:\n                model_response.choices[0].message.content = completion_response[\"choices\"][0][\"message\"][\"content\"]\n            except Exception as e:\n                raise OobaboogaError(\n                    message=str(e),\n                    status_code=raw_response.status_code,\n                )\n\n        model_response.created = int(time.time())\n        model_response.model = model\n        usage: Final = Usage(\n            prompt_tokens=completion_response[\"usage\"][\"prompt_tokens\"],\n            completion_tokens=completion_response[\"usage\"][\"completion_tokens\"],\n            total_tokens=completion_response[\"usage\"][\"total_tokens\"],\n        )\n        setattr(model_response, \"usage\", usage)\n        return model_response\n\n    def validate_environment(\n        self,\n        headers: dict,\n        model: str,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oobabooga/chat/transformation.py#L48-L84","documentation":"After the error checks, the oobabooga transformation copies `completion_response['choices'][0]['message']['content']` into the model response. Any shape mismatch (missing 'choices', empty list, missing 'message'/'content') raises an exception whose str(e) becomes the OobaboogaError message with the upstream status code.","triggerScenarios":"The webui returns JSON without a choices array (e.g. a bare error object without an 'error' key, or a legacy response format), or with an empty choices list, or a completion-style response ({'text': ...}) served on the chat endpoint.","commonSituations":"Version mismatch between text-generation-webui's OpenAI extension and LiteLLM's expected OpenAI chat shape; pointing the chat handler at a legacy/non-chat endpoint; or server stubs returning truncated responses in tests.","solutions":["Inspect the exception message (it shows the KeyError/TypeError path) and the logged original_response to see the actual JSON shape.","Update text-generation-webui so its OpenAI extension returns proper chat.completion JSON, or pin LiteLLM to a version matching your webui version.","Ensure api_base points at /v1-compatible routes and a chat-capable model is loaded."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=\"oobabooga/m\", messages=msgs, api_base=base)\nexcept Exception as e:\n    if \"choices\" in str(e) or \"message\" in str(e):\n        # response shape mismatch: dump server response for diagnosis\n        dump_raw_response(base)","preventionTips":["Pin compatible webui + LiteLLM versions","Return to curl to compare actual vs expected response shape","Never assume non-OpenAI servers emit exact OpenAI chat JSON"],"tags":["oobabooga","response-parsing","schema","chat"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}