{"record":{"id":"29afa8ddcda67a70","repo":"BerriAI/litellm","slug":"litellm-error-prompt-is-not-a-string-prompt","errorCode":null,"errorMessage":"LiteLLM Error - prompt is not a string - {prompt}","messagePattern":"LiteLLM Error - prompt is not a string - (.+?)","errorType":"exception","errorClass":"ReplicateError","httpStatus":400,"severity":"error","filePath":"litellm/llms/replicate/chat/transformation.py","lineNumber":200,"sourceCode":"                    system_prompt = convert_content_list_to_str(first_sys_message)\n                    break\n\n        if model in litellm.custom_prompt_dict:\n            # check if the model has a registered custom prompt\n            model_prompt_details: Final = litellm.custom_prompt_dict[model]\n            prompt = custom_prompt(\n                role_dict=model_prompt_details.get(\"roles\", {}),\n                initial_prompt_value=model_prompt_details.get(\"initial_prompt_value\", \"\"),\n                final_prompt_value=model_prompt_details.get(\"final_prompt_value\", \"\"),\n                bos_token=model_prompt_details.get(\"bos_token\", \"\"),\n                eos_token=model_prompt_details.get(\"eos_token\", \"\"),\n                messages=messages,\n            )\n        else:\n            prompt = prompt_factory(model=model, messages=messages)\n\n        if prompt is None or not isinstance(prompt, str):\n            raise ReplicateError(\n                status_code=400,\n                message=f\"LiteLLM Error - prompt is not a string - {prompt}\",\n                headers={},\n            )\n\n        # If system prompt is supported, and a system prompt is provided, use it\n        if system_prompt is not None:\n            input_data = {\n                \"prompt\": prompt,\n                \"system_prompt\": system_prompt,\n                **optional_params,\n            }\n        # Otherwise, use the prompt as is\n        else:\n            input_data = {\"prompt\": prompt, **optional_params}\n\n        version_id: Final = self.model_to_version_id(model)\n        request_data: Final[dict] = {\"input\": input_data}","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/replicate/chat/transformation.py#L182-L218","documentation":"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.","triggerScenarios":"Triggered when the prompt passed to the Replicate chat transformation is not a string.","commonSituations":"See trigger scenarios.","solutions":["Pass prompt as a string, not a list or other type.","Convert non-string prompts to a string before calling."],"exampleFix":"prompt = str(prompt)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}