BerriAI/litellm · error · ValueError
model is not set. Set either via 'model' or 'engine' param.
Error message
model is not set. Set either via 'model' or 'engine' param.
What it means
Guard in the text-completion entrypoint: no model name was resolved from the 'model' or 'engine' parameters before dispatching to a provider, so LiteLLM has no target to route the completion request to.
Source
Thrown at litellm/main.py:7341
):
# Support for token IDs as prompt (list of integers or list of lists of integers)
messages = [{"role": "user", "content": prompt}]
else:
raise Exception(
f"Unmapped prompt format. Your prompt is neither a list of strings nor a string. prompt={prompt}. File an issue - https://github.com/BerriAI/litellm/issues"
)
kwargs.pop("prompt", None)
if (
_model is not None and (custom_llm_provider == "openai")
): # for openai compatible endpoints - e.g. vllm, call the native /v1/completions endpoint for text completion calls
if _model not in litellm.open_ai_chat_completion_models:
model = "text-completion-openai/" + _model
optional_params.pop("custom_llm_provider", None)
if model is None:
raise ValueError("model is not set. Set either via 'model' or 'engine' param.")
kwargs["text_completion"] = True
response = completion(
model=model,
messages=messages,
*args,
**kwargs,
**optional_params,
)
if kwargs.get("acompletion", False) is True:
return response
if stream is True or kwargs.get("stream", False) is True or isinstance(response, CustomStreamWrapper):
response = TextCompletionStreamWrapper(
completion_stream=response,
model=model,
stream_options=stream_options,
custom_llm_provider=custom_llm_provider,
)
return responseView on GitHub (pinned to 77b7c6c40c)
Solutions
- Pass the model: litellm.text_completion(model='gpt-3.5-turbo-instruct', prompt='hello')
- engine='...' also works for OpenAI-style legacy calls
- Assert your configuration actually resolved a model before calling
Example fix
# before
model = config.get("model_name") # None when key missing
resp = litellm.text_completion(model=model, prompt="hello")
# after
model = config.get("model_name") or "gpt-3.5-turbo-instruct"
resp = litellm.text_completion(model=model, prompt="hello") Defensive patterns
Strategy: validation
Validate before calling
model = config.get("model") or config.get("engine")
if not model:
raise ValueError("text_completion requires 'model' or 'engine' in config")
resp = litellm.text_completion(model=model, prompt=prompt) Try / catch
try:
resp = litellm.text_completion(prompt=prompt, model=model_var)
except ValueError as e:
if "model is not set" in str(e):
raise RuntimeError("no model configured for text completion") from e
raise Prevention
- Fail fast on missing model in config loading, not at call time
- Default the model explicitly so a None never reaches the call
When it happens
Trigger: litellm.text_completion(prompt='hello') with neither model= nor engine= provided, or both explicitly None (e.g. a config variable that failed to resolve).
Common situations: Model name read from a settings dict whose key is missing; config-driven pipelines where the model field is optional; copy-paste code that sets the model after the call.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- model not set
- Batch record for /v1/completions is missing required `prompt
- TogetherAI does not support integers as input
- TogetherAI does not support multiple prompts.
- api_base not set. Set api_base or litellm.api_base for custo
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/161446a17c3383f8.
Report an issue: GitHub.