{"record":{"id":"a751f78456fe6397","repo":"BerriAI/litellm","slug":"embedding-batch-records-do-not-have-a-chat-complet","errorCode":null,"errorMessage":"Embedding batch records do not have a chat-completion equivalent","messagePattern":"Embedding batch records do not have a chat-completion equivalent","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/files/transformation.py","lineNumber":770,"sourceCode":"\n    @staticmethod\n    def _transform_batch_body_to_chat_body(\n        openai_request_body: _OpenAIBatchRecordBody,\n        record_kind: BedrockBatchRecordKind,\n    ) -> Mapping[str, object]:\n        \"\"\"\n        Normalize a non-embedding batch body to the Chat Completions shape the\n        per-provider Bedrock transformations expect.\n        \"\"\"\n        match record_kind:\n            case BedrockBatchRecordKind.TEXT_COMPLETION:\n                return BedrockFilesConfig._transform_text_completion_body_to_chat_body(openai_request_body)\n            case BedrockBatchRecordKind.RESPONSES:\n                return BedrockFilesConfig._transform_responses_body_to_chat_body(openai_request_body)\n            case BedrockBatchRecordKind.CHAT:\n                return openai_request_body\n            case BedrockBatchRecordKind.EMBEDDING:\n                raise ValueError(\"Embedding batch records do not have a chat-completion equivalent\")\n\n    def _map_openai_to_bedrock_params(\n        self,\n        openai_request_body: Mapping[str, Any],\n        model: str,\n        provider: str | None = None,\n    ) -> dict[str, object]:\n        \"\"\"\n        Transform OpenAI request body to Bedrock-compatible modelInput\n        parameters using existing transformation logic.\n\n        Routes to the correct per-provider transformation so that the\n        resulting dict matches the InvokeModel body that Bedrock expects\n        for batch inference.\n        \"\"\"\n        from litellm.types.utils import LlmProviders\n\n        messages: Final = openai_request_body.get(\"messages\", [])","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/files/transformation.py#L752-L788","documentation":"Defensive invariant inside _transform_batch_body_to_chat_body: only TEXT_COMPLETION, RESPONSES and CHAT records can be normalized to a chat body. EMBEDDING records are routed to _map_openai_embedding_to_bedrock_params upstream (line ~896), so a user should never see this from the normal upload flow. Encountering it means the private helper was called directly with an EMBEDDING record, or a LiteLLM regression made classification inconsistent between the routing check and the transform.","triggerScenarios":"Custom code calling BedrockFilesConfig._transform_batch_body_to_chat_body(body, BedrockBatchRecordKind.EMBEDDING) directly; subclass or monkeypatch that changes _classify_batch_record between the routing branch and the transform call; a LiteLLM bug where the record kind is recomputed differently.","commonSituations":"Extending or testing BedrockFilesConfig internals; vendored/forked LiteLLM with modified classification; after upgrading LiteLLM versions that changed record-kind routing.","solutions":["Do not call the private static helper for embedding records — use _map_openai_embedding_to_bedrock_params (or the public create-file path)","If you forked/subclassed the classifier, ensure one classification result is computed once per record and reused","If this surfaces from a plain litellm.create_file call, capture the JSONL line and report a regression at github.com/BerriAI/litellm/issues","Pin the LiteLLM version you validated against until fixed"],"exampleFix":"# before (custom code)\nbody = BedrockFilesConfig._transform_batch_body_to_chat_body(record[\"body\"], BedrockBatchRecordKind.EMBEDDING)\n\n# after\nconfig = BedrockFilesConfig()\nmodel_input = config._map_openai_embedding_to_bedrock_params(record[\"body\"], model=record[\"body\"].get(\"model\", \"\"))","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.types.llms.bedrock import BedrockBatchRecordKind\n\ntry:\n    chat_body = BedrockFilesConfig._transform_batch_body_to_chat_body(body, kind)\nexcept ValueError as e:\n    if \"chat-completion equivalent\" in str(e):\n        raise TypeError(\"embedding records must go through the embedding mapper\") from e\n    raise","preventionTips":["Never call private BedrockFilesConfig helpers for embedding records — use the public create-file flow","Compute record classification once and pass the same value to every downstream branch","Pin your LiteLLM version and regression-test the batch upload path on upgrades"],"tags":["bedrock","batch","internal-invariant","embeddings","litellm"],"backgroundTag":"invariant-violation","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}