{"record":{"id":"b3fe1250121e26f6","repo":"BerriAI/litellm","slug":"completion-response-error-b3fe12","errorCode":null,"errorMessage":"{completion_response[error]}","messagePattern":"\\{completion_response\\[error\\]\\}","errorType":"http","errorClass":"HuggingFaceError","httpStatus":null,"severity":"error","filePath":"litellm/llms/huggingface/embedding/transformation.py","lineNumber":511,"sourceCode":"            logging_obj.post_call(\n                input=request_data,\n                api_key=api_key,\n                original_response=raw_response.text,\n                additional_args={\"complete_input_dict\": request_data},\n            )\n            ## RESPONSE OBJECT\n            try:\n                completion_response = raw_response.json()\n                if isinstance(completion_response, dict):\n                    completion_response = [completion_response]\n            except Exception:\n                raise HuggingFaceError(\n                    message=f\"Original Response received: {raw_response.text}\",\n                    status_code=raw_response.status_code,\n                )\n\n        if isinstance(completion_response, dict) and \"error\" in completion_response:\n            raise HuggingFaceError(\n                message=completion_response[\"error\"],\n                status_code=raw_response.status_code,\n            )\n        return self.convert_to_model_response_object(\n            completion_response=completion_response,\n            model_response=model_response,\n            task=task if task is not None and task in hf_task_list else None,\n            optional_params=optional_params,\n            encoding=encoding,\n            messages=messages,\n            model=model,\n        )\n","sourceCodeStart":493,"sourceCodeEnd":524,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/huggingface/embedding/transformation.py#L493-L524","documentation":"Raised after successful JSON parsing when the completion response is a dict containing an 'error' key — i.e. HuggingFace answered with a structured error payload (auth failure, model not found, rate limit) instead of generations. The upstream status code and error string are forwarded.","triggerScenarios":"completion() against huggingface where the body parses as JSON like {\"error\": \"Authorization header is invalid\"} or {\"error\": \"Model ... does not exist\"}.","commonSituations":"Invalid/expired HF token, referencing a gated model you have not been granted, or hub-side deprecation of the model id.","solutions":["Act on the forwarded error string and status code.","Regenerate the HF token and confirm access to the model on the Hub.","For rate/quota errors, add backoff and reduce request rate."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(...)\nexcept litellm.llms.huggingface.common_utils.HuggingFaceError as e:\n    if 'authorization' in str(e).lower():\n        rotate_hf_token()  # fetch fresh credential and retry once\n    elif 'rate' in str(e).lower():\n        backoff_and_retry()\n    else:\n        raise","preventionTips":["Automate HF token rotation before expiry","Classify upstream error strings (auth vs quota vs model) into distinct handling paths"],"tags":["huggingface","completion","upstream-error","auth"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}