BerriAI/litellm · error · ReplicateError

LiteLLM Error - prompt is not a string - {prompt}

Error message

LiteLLM Error - prompt is not a string - {prompt}

What it means

Type guard in the Replicate request transformation: after prompt construction (including custom_prompt_dict handling), the assembled prompt is not a string (e.g. message content was an unconverted list), so it cannot be serialized for Replicate.

Source

Thrown at litellm/llms/replicate/chat/transformation.py:200

                    system_prompt = convert_content_list_to_str(first_sys_message)
                    break

        if model in litellm.custom_prompt_dict:
            # check if the model has a registered custom prompt
            model_prompt_details: Final = litellm.custom_prompt_dict[model]
            prompt = custom_prompt(
                role_dict=model_prompt_details.get("roles", {}),
                initial_prompt_value=model_prompt_details.get("initial_prompt_value", ""),
                final_prompt_value=model_prompt_details.get("final_prompt_value", ""),
                bos_token=model_prompt_details.get("bos_token", ""),
                eos_token=model_prompt_details.get("eos_token", ""),
                messages=messages,
            )
        else:
            prompt = prompt_factory(model=model, messages=messages)

        if prompt is None or not isinstance(prompt, str):
            raise ReplicateError(
                status_code=400,
                message=f"LiteLLM Error - prompt is not a string - {prompt}",
                headers={},
            )

        # If system prompt is supported, and a system prompt is provided, use it
        if system_prompt is not None:
            input_data = {
                "prompt": prompt,
                "system_prompt": system_prompt,
                **optional_params,
            }
        # Otherwise, use the prompt as is
        else:
            input_data = {"prompt": prompt, **optional_params}

        version_id: Final = self.model_to_version_id(model)
        request_data: Final[dict] = {"input": input_data}

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Pass prompt as a string, not a list or other type.
  2. Convert non-string prompts to a string before calling.

Example fix

prompt = str(prompt)
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Triggered when the prompt passed to the Replicate chat transformation is not a string.

Common situations: See trigger scenarios.


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