BerriAI/litellm · error · OCIError
OCI embed response does not match expected schema: {e}
Error message
OCI embed response does not match expected schema: {e} What it means
After JSON parsing, the response is validated against the OCIEmbedResponse pydantic model (expects fields like modelId and embeddings). If validation fails, this error is raised with status 500 and the pydantic validation message appended. It means OCI returned 200 with JSON, but not in the shape LiteLLM expects.
Source
Thrown at litellm/llms/oci/embed/transformation.py:276
) -> EmbeddingResponse:
if raw_response.status_code != 200:
raise OCIError(
status_code=raw_response.status_code,
message=raw_response.text,
)
try:
json_response: Final = raw_response.json()
except Exception as e:
raise OCIError(
status_code=raw_response.status_code,
message=f"Failed to parse OCI embed response as JSON: {e}",
)
try:
parsed: Final = OCIEmbedResponse(**json_response)
except Exception as e:
raise OCIError(
status_code=500,
message=f"OCI embed response does not match expected schema: {e}",
)
model_response.model = parsed.modelId
model_response.data = [
{
"object": "embedding",
"index": i,
"embedding": embedding,
}
for i, embedding in enumerate(parsed.embeddings)
]
if parsed.inputTextTokenCounts is not None:
# Actual OCI API returns per-input token counts — sum for total usage
total: Final = sum(parsed.inputTextTokenCounts)
model_response.usage = Usage(prompt_tokens=total, total_tokens=total)View on GitHub (pinned to 6c2dcb801b)
Solutions
- Ensure the model prefix matches the actual backend: use `openai/` (or the appropriate provider) for OpenAI-compatible endpoints, `oci/` only for real OCI generative-ai.
- If testing, make stub responses match the OCI embed schema: {"modelId": "...", "embeddings": [[...]]}.
- Check for LiteLLM updates if OCI changed its response format — the adapter's pydantic model may need updating.
Example fix
# before litellm.embedding(model="oci/my-model", api_base="http://localhost:8000") # vLLM behind it # after litellm.embedding(model="openai/my-model", api_base="http://localhost:8000/v1")
Defensive patterns
Strategy: validation
Try / catch
try:
resp = litellm.embedding(model=model_name, input=texts)
except Exception as e:
if "does not match expected schema" in str(e):
# provider/model prefix mismatch: response shape isn't OCI's
assert not model_name.startswith("oci/") or is_real_oci_endpoint(api_base) Prevention
- Match model prefix (oci/ vs openai/) to the actual backend
- Keep canned test fixtures provider-specific
- Upgrade LiteLLM when OCI API shapes change
When it happens
Trigger: An OpenAI-compatible endpoint (e.g. a self-hosted vLLM with an OpenAI-style `{"data": [...]}` body) is wired to the oci provider, so the response lacks `modelId`/`embeddings`. Also OCI API evolution adding/removing fields, or a mock/stub server returning a simplified payload.
Common situations: Setting a custom api_base to an OpenAI-compatible server but keeping the `oci/` model prefix, so the OpenAI-shaped response fails OCI schema validation; or using recorded/canned responses in tests that were captured from a different provider.
Related errors
- Failed to parse OCI embed response as JSON: {e}
- No embedding data found in response: {response}
- No image URL in BFL result
- No polling_url in BFL response
- Response cannot be casted to CohereChatResult: {e}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/8d5714e57590923c.
Report an issue: GitHub.