BerriAI/litellm · error · SambaNovaError
{raw_response.text}
Error message
{raw_response.text} What it means
For SambaNova embeddings, LiteLLM parses the HTTP response with .json(); on failure it raises SambaNovaError whose message is the raw response body text and whose status/headers come from the original response. The body text is the primary diagnostic: it usually reveals why the server returned non-JSON.
Source
Thrown at litellm/llms/sambanova/embedding/transformation.py:117
"model": model,
**optional_params,
}
def transform_embedding_response(
self,
model: str,
raw_response: httpx.Response,
model_response: EmbeddingResponse,
logging_obj: LiteLLMLoggingObj,
api_key: str | None,
request_data: dict,
optional_params: dict,
litellm_params: dict,
) -> EmbeddingResponse:
try:
raw_response_json: Final = raw_response.json()
except Exception:
raise SambaNovaError(
message=raw_response.text,
status_code=raw_response.status_code,
headers=raw_response.headers,
)
model_response.model = raw_response_json.get("model")
model_response.data = raw_response_json.get("data")
model_response.object = raw_response_json.get("object")
usage: Final = Usage(
prompt_tokens=raw_response_json.get("usage", {}).get("prompt_tokens", 0),
total_tokens=raw_response_json.get("usage", {}).get("total_tokens", 0),
)
model_response.usage = usage
return model_response
def get_error_class(self, error_message: str, status_code: int, headers: dict | httpx.Headers) -> BaseLLMException:View on GitHub (pinned to 77b7c6c40c)
Solutions
- Read the body text in the error - an HTML title like '404 Not Found' means the URL path is wrong.
- Verify api_base: LiteLLM appends /embeddings only when missing, so do not double-append it yourself.
- Check the API key (SAMBANOVA_API_KEY) is set and valid for that deployment.
- If 5xx, retry later or check the SambaNova status page / your self-hosted gateway health.
Example fix
# before - path already contains /embeddings and a typo api_base='https://api.sambanova.ai/v1/embeddingsx' # after - clean base, /embeddings appended automatically api_base='https://api.sambanova.ai/v1'
Defensive patterns
Strategy: try-catch
Try / catch
from litellm.llms.sambanova.embeddings import SambaNovaError
try:
resp = litellm.embedding(model='sambanova/E5-Embeddings-300M', input=texts, api_base=API_BASE)
except SambaNovaError as e:
log.error('sambanova returned status %s body=%s', e.status_code, e.message)
raise Prevention
- Do not append /embeddings yourself - LiteLLM appends it when missing.
- Canary the /embeddings URL with curl after any gateway or route change.
When it happens
Trigger: api_base pointing at a wrong path (HTML 404 page), an auth error returned as plain text, a gateway/WAF error page, or an empty body from a 502/503 outage at the SambaNova endpoint.
Common situations: api_base manually set to a URL that already includes /embeddings plus a typo; expired API key producing a text 401; internal SambaNova Enterprise LaunchPad route changed between environments.
Understand the failure class
Background: "Invalid JSON response" and "Failed to parse response" errors: when an API answers 200 but the body isn't the JSON your library expected — this error's family across 28 libraries.
Related errors
- Failed to parse response: {e}
- Mavvrik FOCUS destination: response missing 'url' field: {re
- AgentCore: Failed to read/parse JSON response body: {e}
- No embedding data found in response: {response}
- Error parsing BFL response: {e}
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/cca76b2ecbb2e0cd.
Report an issue: GitHub.