BerriAI/litellm · error · BaseLLMException
error_msg (upstream response error message)
Error message
error_msg (upstream response error message)
What it means
Raised by litellm's container handler (sync path) when a container-provider HTTP endpoint returns a JSON body containing an 'error' key. LiteLLM wraps the upstream error message and status code in a BaseLLMException so callers see a uniform exception type. It mirrors whatever failure the upstream container service (e.g. a self-hosted model server) reported.
Source
Thrown at litellm/llms/custom_httpx/container_handler.py:283
if is_multipart and "file" in kwargs:
files, headers = _prepare_multipart_file_upload(kwargs["file"], headers)
response = http_client.post(url=url, headers=headers, params=effective_params, files=files)
else:
response = http_client.post(url=url, headers=headers, params=effective_params)
else:
raise ValueError(f"Unsupported HTTP method: {method}")
# For binary responses, return raw content
if returns_binary:
return response.content
# Check for error response
response_json: Final = response.json()
if "error" in response_json:
from litellm.llms.base_llm.chat.transformation import BaseLLMException
error_msg: Final = response_json.get("error", {}).get("message", str(response_json))
raise BaseLLMException(
status_code=response.status_code,
message=error_msg,
headers=dict(response.headers),
)
# Parse response
response_type: Final = RESPONSE_TYPES.get(endpoint_config["response_type"])
if response_type:
return response_type(**response_json)
return response_json
except Exception as e:
raise e
async def _async_handle(
self,
endpoint_name: str,
container_provider_config: "BaseContainerConfig",View on GitHub (pinned to 6c2dcb801b)
Solutions
- Inspect the exception's message field — it is the upstream service's own error message and names the real cause
- Check exception.status_code and headers to see if it is auth (401/403), not-found (404), or rate-limit (429) related
- Verify the endpoint config in the container provider config: correct api_base, path, and request params for the endpoint you call
- If 401/403, fix the credentials/token passed to the container provider
- If 429/5xx, retry with backoff or check container service health
Example fix
# before
resp = container_handler.sync_request(endpoint_name="files", ...)
# after
from litellm.llms.base_llm.chat.transformation import BaseLLMException
try:
resp = container_handler.sync_request(endpoint_name="files", ...)
except BaseLLMException as e:
print(e.status_code, e.message) # upstream's real error
raise Defensive patterns
Strategy: try-catch
Try / catch
from litellm.llms.base_llm.chat.transformation import BaseLLMException
try:
resp = container_handler.sync_request(endpoint_name=name, ...)
except BaseLLMException as e:
if e.status_code in (429, 500, 502, 503):
raise TransientError(e.message) from e
raise Prevention
- Validate IDs and params before container endpoint calls
- Log BaseLLMException.status_code and headers alongside the message for faster triage
When it happens
Trigger: Calling a container-based provider endpoint (e.g. Pinecone/container REST route) where the upstream returns JSON like {"error": {"message": "..."}} — bad request payloads, invalid IDs, upstream 4xx/5xx with JSON error bodies, or expired/invalid credentials on the container service.
Common situations: Misconfigured api_base pointing at a container service that rejects the request; deleting or fetching a resource (file, index, job) that does not exist; upstream container service rate limiting or internal errors returned as JSON.
Related errors
- Failed to transform Braintrust response: {str(e)}
- Error apply_db_fixes: {str(e)}
- Error getting prompt from Humanloop: {e.response.text}
- {str(e)}
- _body (masked response body)
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/bcb755058e76c592.
Report an issue: GitHub.