BerriAI/litellm · error · NLPCloudError
{completion_response["error"]}
Error message
{completion_response["error"]} What it means
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.
Source
Thrown at litellm/llms/nlp_cloud/chat/transformation.py:194
encoding: Any,
api_key: str | None = None,
json_mode: bool | None = None,
) -> ModelResponse:
## LOGGING
logging_obj.post_call(
input=None,
api_key=api_key,
original_response=raw_response.text,
additional_args={"complete_input_dict": request_data},
)
## RESPONSE OBJECT
try:
completion_response: Final = raw_response.json()
except Exception:
raise NLPCloudError(message=raw_response.text, status_code=raw_response.status_code)
if "error" in completion_response:
raise NLPCloudError(
message=completion_response["error"],
status_code=raw_response.status_code,
)
else:
try:
if len(completion_response["generated_text"]) > 0:
model_response.choices[0].message.content = completion_response["generated_text"]
except Exception:
raise NLPCloudError(
message=json.dumps(completion_response),
status_code=raw_response.status_code,
)
## CALCULATING USAGE - baseten charges on time, not tokens - have some mapping of cost here.
prompt_tokens: Final = completion_response["nb_input_tokens"]
completion_tokens: Final = completion_response["nb_generated_tokens"]
model_response.created = int(time.time())View on GitHub (pinned to 6c2dcb801b)
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.
Example fix
# before out = litellm.completion(model="nlp_cloud/wrong-engine-name", messages=msgs) # after out = litellm.completion(model="nlp_cloud/finetuned-llama-3-70b", messages=msgs)
Defensive patterns
Strategy: try-catch
Validate before calling
ALLOWED_NLPCLOUD_MODELS = {"finetuned-llama-3-70b", "chatdolphin-30b"} # keep in sync with your account
if model_name not in ALLOWED_NLPCLOUD_MODELS:
raise ValueError(f"engine {model_name!r} not enabled on your NLP Cloud account") Try / catch
from litellm.exceptions import APIError
try:
out = litellm.completion(model=f"nlp_cloud/{engine}", messages=msgs)
except APIError as e:
if "error" in str(e).lower() and getattr(e, "status_code", None) in (400, 401, 402, 403):
raise RuntimeError(f"NLP Cloud rejected request: {e}") from e # do not retry
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Using an engine name not enabled on the account, exhausted GPU credits, or sending parameters NLP Cloud does not accept.
Related errors
- {raw_response.text}
- {json.dumps(completion_response)}
- completion_response["error"]
- Invalid arg. Model cannot be none.
- Model is None and does not exist in passed completion_respon
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/57264fde95896566.
Report an issue: GitHub.