xtekky/gpt4free · error · ValueError
Model "{model_file}" not found.
Error message
Model "{model_file}" not found. What it means
Thrown by LocalProvider.create_completion() when the cataloged model file is not present under the models directory and the interactive download prompt was declined (or received anything other than y/Y). Note it calls input(): in a non-TTY context (server, cron, subprocess) input() raises EOFError first, so this exact ValueError mostly appears in interactive sessions.
Source
Thrown at g4f/locals/provider.py:54
def create_completion(
model: str, messages: Messages, stream: bool = False, **kwargs
):
global MODEL_LIST
if MODEL_LIST is None:
MODEL_LIST = get_models()
if model not in MODEL_LIST:
raise ValueError(f'Model "{model}" not found / not yet implemented')
model = MODEL_LIST[model]
model_file = model["path"]
model_dir = find_model_dir(model_file)
if not os.path.isfile(os.path.join(model_dir, model_file)):
print(f'Model file "models/{model_file}" not found.')
download = input(f"Do you want to download {model_file}? [y/n]: ")
if download in ["y", "Y"]:
GPT4All.download_model(model_file, model_dir)
else:
raise ValueError(f'Model "{model_file}" not found.')
model = GPT4All(
model_name=model_file,
# n_threads=8,
verbose=False,
allow_download=False,
model_path=model_dir,
)
system_message = "\n".join(
message["content"] for message in messages if message["role"] == "system"
)
if system_message:
system_message = "A chat between a curious user and an artificial intelligence assistant."
prompt_template = "USER: {0}\nASSISTANT: "
conversation = (
"\n".join(View on GitHub (pinned to 973504e177)
Solutions
- Run once interactively and answer 'y' to let GPT4All.download_model fetch the file.
- Or pre-download manually: place the GGUF from the catalog entry into the models dir with the exact 'path' filename from models.yaml.
- For headless servers, pre-populate the models directory in the image/deploy step so the prompt never triggers (it also avoids the EOFError from input()).
Example fix
// before # headless call with no model file on disk -> input() EOFError / decline -> ValueError LocalProvider.create_completion(model=name, messages=msgs) // after # pre-provision the file (deploy step): # curl -L -o models/<model_file_from_models_yaml> <gguf_url> LocalProvider.create_completion(model=name, messages=msgs)
Defensive patterns
Strategy: validation
Validate before calling
from g4f.locals.provider import get_models, find_model_dir
import os
def model_file_present(model: str) -> bool:
entry = get_models().get(model)
if entry is None:
return False
d = find_model_dir(entry["path"])
return os.path.isfile(os.path.join(d, entry["path"])) Try / catch
try:
LocalProvider.create_completion(model=model, messages=msgs)
except (EOFError, ValueError) as e:
# EOFError: input() in non-TTY; ValueError: download declined
raise RuntimeError(f"model file missing for {model}; pre-provision it") from e Prevention
- Pre-download model files in your deploy step; never rely on the interactive prompt in servers.
- Verify file names match models.yaml 'path' entries exactly.
When it happens
Trigger: First use of a local model whose GGUF file was never downloaded; answering 'n' at the 'Do you want to download ...? [y/n]' prompt; a models dir where the file was deleted or the filename in models.yaml doesn't match what's on disk.
Common situations: Fresh installs expecting local models to be bundled (they are not); deployments where the prompt hangs or EOFs because stdin is closed; partial downloads leaving a wrong-sized/absent file.
Related errors
- Model "{model}" not found / not yet implemented
- Install "gpt4all" package | pip install -U g4f[local]
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/5c7f005a5695b870.
Report an issue: GitHub.