BerriAI/litellm · error · Exception
Error: {raw_response.status_code} {raw_response.text}
Error message
Error: {raw_response.status_code} {raw_response.text} What it means
Thrown by the Vertex AI multimodal embeddings response transformer when the upstream HTTP status is not 200. The message embeds the raw status code and response body from Vertex AI, so the real cause (auth, quota, payload) is whatever the provider returned. It is the catch-all branch that runs before the response JSON is parsed.
Source
Thrown at litellm/llms/vertex_ai/multimodal_embeddings/transformation.py:209
if "outputDimensionality" in optional_params:
request_data["parameters"] = {"dimension": optional_params["outputDimensionality"]}
return cast(dict, request_data)
def transform_embedding_response(
self,
model: str,
raw_response: Response,
model_response: EmbeddingResponse,
logging_obj: LiteLLMLoggingObj,
api_key: str | None,
request_data: dict,
optional_params: dict,
litellm_params: dict,
) -> EmbeddingResponse:
if raw_response.status_code != 200:
raise Exception(f"Error: {raw_response.status_code} {raw_response.text}")
_json_response: Final = raw_response.json()
if "predictions" not in _json_response:
raise InternalServerError(
message=f"embedding response does not contain 'predictions', got {_json_response}",
llm_provider="vertex_ai",
model=model,
)
_predictions: Final = _json_response["predictions"]
vertex_predictions: Final = MultimodalPredictions(predictions=_predictions)
model_response.data = self.transform_embedding_response_to_openai(predictions=vertex_predictions)
model_response.model = model
model_response.usage = self.calculate_usage(
request_data=cast(VertexMultimodalEmbeddingRequest, request_data),
vertex_predictions=vertex_predictions,
)
View on GitHub (pinned to 77b7c6c40c)
Solutions
- Read the status code and body inside the message - they come verbatim from Vertex AI and name the real failure
- On 401/403: refresh the service-account key and verify GOOGLE_APPLICATION_CREDENTIALS / vertex_credentials and the project
- On 429: check Vertex AI quotas for the embedding model and retry with exponential backoff
- On 400: verify the image is a valid base64 data URI or public URL and that input text is within model limits
- Confirm the model name and that it is available in vertex_location (default us-central1)
Example fix
// before
resp = litellm.embedding(model='vertex_ai/multimodalembedding@001', input=[{'text': 'hi'}])
// after - surface the upstream status code and body Vertex AI returned
try:
resp = litellm.embedding(model='vertex_ai/multimodalembedding@001', input=[{'text': 'hi'}])
except Exception as e:
msg = str(e) # 'Error: 429 {...}' - parse the code and act on it
if ' 429 ' in msg:
time.sleep(30) # quota hit - back off before retrying
resp = litellm.embedding(model='vertex_ai/multimodalembedding@001', input=[{'text': 'hi'}]) Defensive patterns
Strategy: try-catch
Validate before calling
import base64
def valid_image_b64(image_b64: str) -> bool:
try:
base64.b64decode(image_b64, validate=True)
return True
except Exception:
return False
# run before the call to avoid the common 400 case
assert valid_image_b64(image_b64), 'invalid base64 image payload' Try / catch
try:
resp = litellm.embedding(model=model, input=inputs)
except Exception as e:
# message embeds the upstream '{status_code} {body}' from Vertex AI
log.error('vertex multimodal embedding failed: %s', e)
if ' 429 ' in str(e):
time.sleep(30)
resp = litellm.embedding(model=model, input=inputs)
else:
raise Prevention
- Verify GCP credentials and quota before deploying
- Keep image payloads within the model's documented size and count limits
- Wrap calls in retry with backoff for 429 responses
- Pin vertex_location to a region where the model is enabled
When it happens
Trigger: Calling litellm.embedding() with a Vertex AI multimodal embedding model and receiving any non-200 from the :predict endpoint: 401/403 from bad or expired service-account credentials, 429 from exhausted embedding quota, 400 from malformed instances (invalid image bytes, text over the limit), or 404 from a wrong model name or location.
Common situations: Expired or missing GOOGLE_APPLICATION_CREDENTIALS; model not enabled in the chosen vertex_location; images sent as invalid base64 or unreachable URLs; quota exceeded on a busy project; typo in the model id.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- response.text
- Error: {response.status_code} {response.text}
- {err.response.text}
- embedding response does not contain 'predictions', got {_jso
- WXO: No run_id in response: {run_data}
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/60d4dc916c4acbb4.
Report an issue: GitHub.