BerriAI/litellm · error · ValueError

Bedrock batch embedding requires one input per JSONL…

Error message

Bedrock batch embedding requires one input per JSONL record. Got a list with {len(raw_input)} items for model={model}; emit one JSONL line per input string instead.

What it means

Shape guard for batch embeddings: the record's 'input' is a multi-element list, but Bedrock InvokeModel for Titan v2 accepts exactly one string per call, so the caller must emit one JSONL line per input string.

Solutions

  1. Emit one JSONL line per input string instead of a list of inputs.
  2. Split multi-input records into separate batch records.
  3. Check the batch file generation logic for batching of inputs.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/llms/bedrock/files/transformation.py:618 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/7387d7f1b6004aef. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/bedrock/files/transformation.py:618

          - Pre-tokenized inputs (List[int], List[List[int]]) -> NotImplementedError
          - Any other type -> ValueError

        Extracted so the validation can be exercised in isolation and so
        future embedding-provider branches (Titan G1, Cohere) can reuse it
        without duplicating the type-shaping logic.
        """
        if raw_input is None:
            raise ValueError(f"Embedding batch record is missing required `input` field: model={model}")

        # Bedrock InvokeModel for Titan v2 takes exactly one string `inputText`
        # per call. Pre-tokenized inputs and multi-element string lists are
        # explicitly unsupported so callers emit one JSONL line per embedding
        # instead of relying on us to silently fan out or concatenate.
        if isinstance(raw_input, list):
            if len(raw_input) == 1:
                candidate = raw_input[0]
            else:
                raise ValueError(
                    "Bedrock batch embedding requires one input per JSONL "
                    "record. Got a list with "
                    f"{len(raw_input)} items for model={model}; emit one "
                    "JSONL line per input string instead."
                )
        else:
            candidate = raw_input

        # Catches pre-tokenized inputs (List[int] from OpenAI spec, or a
        # single int slipping past the list-unwrap above).
        # NOTE: bool is a subclass of int but treating True/False as a token
        # is meaningless either way, so the broad check is fine.
        if isinstance(candidate, (list, int)):
            raise NotImplementedError(
                "Bedrock Titan v2 batch embedding does not support "
                "pre-tokenized integer inputs. Pass `input` as a string "
                f"(model={model})."
            )

View on GitHub (pinned to 77b7c6c40c)