BerriAI/litellm · error · ValueError
Message {i} must have a 'content' field
Error message
Message {i} must have a 'content' field What it means
Error "Message {i} must have a 'content' field" thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/anthropic/count_tokens/transformation.py:107
"""
if not model:
raise ValueError("model parameter is required")
if not messages:
raise ValueError("messages parameter is required")
if not isinstance(messages, list):
raise ValueError("messages must be a list")
for i, message in enumerate(messages):
if not isinstance(message, dict):
raise ValueError(f"Message {i} must be a dictionary")
if "role" not in message:
raise ValueError(f"Message {i} must have a 'role' field")
if "content" not in message:
raise ValueError(f"Message {i} must have a 'content' field")
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Add a 'content' field to each message.
When it happens
Trigger: Thrown at litellm/llms/anthropic/count_tokens/transformation.py:107 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/73c72edbbe44b7d2.
Report an issue: GitHub.