{"record":{"id":"8d5714e57590923c","repo":"BerriAI/litellm","slug":"oci-embed-response-does-not-match-expected-schema","errorCode":null,"errorMessage":"OCI embed response does not match expected schema: {e}","messagePattern":"OCI embed response does not match expected schema: (.+?)","errorType":"exception","errorClass":"OCIError","httpStatus":500,"severity":"error","filePath":"litellm/llms/oci/embed/transformation.py","lineNumber":276,"sourceCode":"    ) -> EmbeddingResponse:\n        if raw_response.status_code != 200:\n            raise OCIError(\n                status_code=raw_response.status_code,\n                message=raw_response.text,\n            )\n\n        try:\n            json_response: Final = raw_response.json()\n        except Exception as e:\n            raise OCIError(\n                status_code=raw_response.status_code,\n                message=f\"Failed to parse OCI embed response as JSON: {e}\",\n            )\n\n        try:\n            parsed: Final = OCIEmbedResponse(**json_response)\n        except Exception as e:\n            raise OCIError(\n                status_code=500,\n                message=f\"OCI embed response does not match expected schema: {e}\",\n            )\n\n        model_response.model = parsed.modelId\n        model_response.data = [\n            {\n                \"object\": \"embedding\",\n                \"index\": i,\n                \"embedding\": embedding,\n            }\n            for i, embedding in enumerate(parsed.embeddings)\n        ]\n\n        if parsed.inputTextTokenCounts is not None:\n            # Actual OCI API returns per-input token counts — sum for total usage\n            total: Final = sum(parsed.inputTextTokenCounts)\n            model_response.usage = Usage(prompt_tokens=total, total_tokens=total)","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oci/embed/transformation.py#L258-L294","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nlitellm.embedding(model=\"oci/my-model\", api_base=\"http://localhost:8000\")  # vLLM behind it\n\n# after\nlitellm.embedding(model=\"openai/my-model\", api_base=\"http://localhost:8000/v1\")","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.embedding(model=model_name, input=texts)\nexcept Exception as e:\n    if \"does not match expected schema\" in str(e):\n        # provider/model prefix mismatch: response shape isn't OCI's\n        assert not model_name.startswith(\"oci/\") or is_real_oci_endpoint(api_base)","preventionTips":["Match model prefix (oci/ vs openai/) to the actual backend","Keep canned test fixtures provider-specific","Upgrade LiteLLM when OCI API shapes change"],"tags":["oci","embedding","schema","response-parsing","provider-mismatch"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}