BerriAI/litellm · error · ValueError
model is required
Error message
model is required
What it means
validate_input_kwargs on ResponsesToCompletionBridgeHandler raises this when the kwargs dict is missing 'model' or it is not a str. These kwargs are normally assembled internally by litellm's completion pipeline; a user only sees this error when invoking the bridge handler directly (it is an internal API) or when a fork/older pipeline fails to thread the model through.
Source
Thrown at litellm/completion_extras/litellm_responses_transformation/handler.py:110
response_obj: Final = getattr(completed, "response", None) if completed else None
if response_obj is None:
raise ValueError("Stream ended without a completed response")
hidden_params: Final = getattr(stream_iter, "_hidden_params", None)
response: Final = self._coerce_response_object(response_obj, hidden_params)
if not isinstance(response, ResponsesAPIResponse):
raise ValueError("Stream completed response is invalid")
return response
def validate_input_kwargs(self, kwargs: dict) -> ResponsesToCompletionBridgeHandlerInputKwargs:
from litellm import LiteLLMLoggingObj
from litellm.types.utils import ModelResponse
typed_kwargs: Final[dict[str, object]] = kwargs
model: Final = typed_kwargs.get("model")
if model is None or not isinstance(model, str):
raise ValueError("model is required")
custom_llm_provider: Final = typed_kwargs.get("custom_llm_provider")
if custom_llm_provider is None or not isinstance(custom_llm_provider, str):
raise ValueError("custom_llm_provider is required")
messages: Final = typed_kwargs.get("messages")
if messages is None or not isinstance(messages, list):
raise ValueError("messages is required")
optional_params: Final = typed_kwargs.get("optional_params")
if optional_params is None or not isinstance(optional_params, dict):
raise ValueError("optional_params is required")
litellm_params: Final = typed_kwargs.get("litellm_params")
if litellm_params is None or not isinstance(litellm_params, dict):
raise ValueError("litellm_params is required")
headers: Final = typed_kwargs.get("headers")View on GitHub (pinned to 6c2dcb801b)
Solutions
- Call litellm.completion()/acompletion() instead of the bridge handler directly — it constructs all required kwargs for you
- If calling directly, include model as a non-empty string in the kwargs dict
- Check the ResponsesToCompletionBridgeHandlerInputKwargs TypedDict (handler.py:16) for the full required key set
Example fix
# before
handler = ResponsesToCompletionBridgeHandler()
result = await handler.acompletion({"messages": msgs, ...}) # no model
# after
result = await litellm.acompletion(model="openai/gpt-4o", messages=msgs) Defensive patterns
Strategy: validation
Validate before calling
def has_model_kwarg(kwargs: dict) -> bool:
return isinstance(kwargs.get("model"), str) and bool(kwargs["model"]) Type guard
def is_valid_bridge_kwargs(kwargs: dict) -> bool:
return isinstance(kwargs.get("model"), str) Prevention
- Prefer litellm.completion over the internal bridge handler
- Type your kwargs against ResponsesToCompletionBridgeHandlerInputKwargs
- Validate required keys before direct invocation
When it happens
Trigger: Instantiating ResponsesToCompletionBridgeHandler and calling its async_completion or validate_input_kwargs with a hand-built kwargs dict that omits 'model' or sets it to a non-string (e.g. None, int).
Common situations: Custom integrations or tests that call the bridge handler directly instead of litellm.completion; copy-pasted kwargs from an older litellm version whose pipeline keys changed.
Related errors
- custom_llm_provider is required
- messages is required
- optional_params is required
- litellm_params is required
- headers is required
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/005334db1c263946.
Report an issue: GitHub.