{"record":{"id":"161446a17c3383f8","repo":"BerriAI/litellm","slug":"model-is-not-set-set-either-via-model-or-engin","errorCode":null,"errorMessage":"model is not set. Set either via 'model' or 'engine' param.","messagePattern":"model is not set\\. Set either via 'model' or 'engine' param\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/main.py","lineNumber":7341,"sourceCode":"    ):\n        # Support for token IDs as prompt (list of integers or list of lists of integers)\n        messages = [{\"role\": \"user\", \"content\": prompt}]\n    else:\n        raise Exception(\n            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\"\n        )\n\n    kwargs.pop(\"prompt\", None)\n\n    if (\n        _model is not None and (custom_llm_provider == \"openai\")\n    ):  # for openai compatible endpoints - e.g. vllm, call the native /v1/completions endpoint for text completion calls\n        if _model not in litellm.open_ai_chat_completion_models:\n            model = \"text-completion-openai/\" + _model\n            optional_params.pop(\"custom_llm_provider\", None)\n\n    if model is None:\n        raise ValueError(\"model is not set. Set either via 'model' or 'engine' param.\")\n    kwargs[\"text_completion\"] = True\n    response = completion(\n        model=model,\n        messages=messages,\n        *args,\n        **kwargs,\n        **optional_params,\n    )\n    if kwargs.get(\"acompletion\", False) is True:\n        return response\n    if stream is True or kwargs.get(\"stream\", False) is True or isinstance(response, CustomStreamWrapper):\n        response = TextCompletionStreamWrapper(\n            completion_stream=response,\n            model=model,\n            stream_options=stream_options,\n            custom_llm_provider=custom_llm_provider,\n        )\n        return response","sourceCodeStart":7323,"sourceCodeEnd":7359,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/main.py#L7323-L7359","documentation":"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.","triggerScenarios":"litellm.text_completion(prompt='hello') with neither model= nor engine= provided, or both explicitly None (e.g. a config variable that failed to resolve).","commonSituations":"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.","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"],"exampleFix":"# before\nmodel = config.get(\"model_name\")  # None when key missing\nresp = litellm.text_completion(model=model, prompt=\"hello\")\n\n# after\nmodel = config.get(\"model_name\") or \"gpt-3.5-turbo-instruct\"\nresp = litellm.text_completion(model=model, prompt=\"hello\")","handlingStrategy":"validation","validationCode":"model = config.get(\"model\") or config.get(\"engine\")\nif not model:\n    raise ValueError(\"text_completion requires 'model' or 'engine' in config\")\nresp = litellm.text_completion(model=model, prompt=prompt)","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.text_completion(prompt=prompt, model=model_var)\nexcept ValueError as e:\n    if \"model is not set\" in str(e):\n        raise RuntimeError(\"no model configured for text completion\") from e\n    raise","preventionTips":["Fail fast on missing model in config loading, not at call time","Default the model explicitly so a None never reaches the call"],"tags":["litellm","text-completion","model","required-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}