{"record":{"id":"57264fde95896566","repo":"BerriAI/litellm","slug":"completion-response-error-57264f","errorCode":null,"errorMessage":"{completion_response[\"error\"]}","messagePattern":"\\{completion_response\\[\"error\"\\]\\}","errorType":"http","errorClass":"NLPCloudError","httpStatus":null,"severity":"error","filePath":"litellm/llms/nlp_cloud/chat/transformation.py","lineNumber":194,"sourceCode":"        encoding: Any,\n        api_key: str | None = None,\n        json_mode: bool | None = None,\n    ) -> ModelResponse:\n        ## LOGGING\n        logging_obj.post_call(\n            input=None,\n            api_key=api_key,\n            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 NLPCloudError(message=raw_response.text, status_code=raw_response.status_code)\n        if \"error\" in completion_response:\n            raise NLPCloudError(\n                message=completion_response[\"error\"],\n                status_code=raw_response.status_code,\n            )\n        else:\n            try:\n                if len(completion_response[\"generated_text\"]) > 0:\n                    model_response.choices[0].message.content = completion_response[\"generated_text\"]\n            except Exception:\n                raise NLPCloudError(\n                    message=json.dumps(completion_response),\n                    status_code=raw_response.status_code,\n                )\n\n        ## CALCULATING USAGE - baseten charges on time, not tokens - have some mapping of cost here.\n        prompt_tokens: Final = completion_response[\"nb_input_tokens\"]\n        completion_tokens: Final = completion_response[\"nb_generated_tokens\"]\n\n        model_response.created = int(time.time())","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/nlp_cloud/chat/transformation.py#L176-L212","documentation":"Raised by litellm's NLPCloud chat transformer when the parsed JSON response body contains an \"error\" key — NLP Cloud rejected the request and returned a structured error. The message is the upstream error value and the upstream HTTP status code is attached to the NLPCloudError.","triggerScenarios":"Calling litellm.completion() with an nlp_cloud/* model when NLP Cloud returns {\"error\": ...}: invalid model/engine name for your account, malformed request payload, insufficient credits, or an auth error reported in-band.","commonSituations":"Using an engine name not enabled on the account, exhausted GPU credits, or sending parameters NLP Cloud does not accept.","solutions":["Read the message text — it is NLP Cloud's own error description (e.g. 'model not found').","Confirm the model string after nlp_cloud/ matches an engine available to your account.","Check account credits/quotas on the NLP Cloud dashboard.","Strip unsupported optional params from the completion call."],"exampleFix":"# before\nout = litellm.completion(model=\"nlp_cloud/wrong-engine-name\", messages=msgs)\n\n# after\nout = litellm.completion(model=\"nlp_cloud/finetuned-llama-3-70b\", messages=msgs)","handlingStrategy":"try-catch","validationCode":"ALLOWED_NLPCLOUD_MODELS = {\"finetuned-llama-3-70b\", \"chatdolphin-30b\"}  # keep in sync with your account\nif model_name not in ALLOWED_NLPCLOUD_MODELS:\n    raise ValueError(f\"engine {model_name!r} not enabled on your NLP Cloud account\")","typeGuard":null,"tryCatchPattern":"from litellm.exceptions import APIError\ntry:\n    out = litellm.completion(model=f\"nlp_cloud/{engine}\", messages=msgs)\nexcept APIError as e:\n    if \"error\" in str(e).lower() and getattr(e, \"status_code\", None) in (400, 401, 402, 403):\n        raise RuntimeError(f\"NLP Cloud rejected request: {e}\") from e  # do not retry\n    raise","preventionTips":["Validate engine names against your account's enabled list.","Monitor account credits to avoid quota errors mid-run.","Distinguish in-band errors (this) from gateway failures by status code."],"tags":["nlp-cloud","chat","upstream-error","model-name"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}