xtekky/gpt4free · error · ModelNotFoundError
Model is not supported: {model} in: {cls.__name__}
Error message
Model is not supported: {model} in: {cls.__name__} What it means
Raised by HuggingFaceMedia when the model-to-provider mapping fetched from the HuggingFace router (filtered/merged for replicate, together, hf-inference) ends up empty. ModelNotFoundError means the router API knows no serving provider for the requested model id, so there is nothing to dispatch to.
Source
Thrown at g4f/Provider/needs_auth/hf/HuggingFaceMedia.py:163
if model and ":" in model:
model, selected_provider = model.split(":", 1)
elif not model:
model = cls.get_models()[0]
prompt = format_media_prompt(messages, prompt)
provider_mapping = await cls.get_mapping(model, api_key)
headers = {
"Accept-Encoding": "gzip, deflate",
"Content-Type": "application/json",
"Prefer": "wait",
}
new_mapping = {
"hf-free" if key == "hf-inference" else key: value
for key, value in provider_mapping.items()
if key in ["replicate", "together", "hf-inference"]
}
provider_mapping = {**new_mapping, **provider_mapping}
if not provider_mapping:
raise ModelNotFoundError(
f"Model is not supported: {model} in: {cls.__name__}"
)
async def generate(extra_body: dict, aspect_ratio: str = None):
last_response = None
for provider_key, provider in provider_mapping.items():
if selected_provider is not None and selected_provider != provider_key:
continue
provider_info = ProviderInfo(
**{
**cls.get_dict(),
"label": f"HuggingFace ({provider_key})",
"url": f"{cls.url}/{model}",
}
)
base_url = f"https://router.huggingface.co/{provider_key}"
task = provider["task"]View on GitHub (pinned to 973504e177)
Solutions
- Verify the exact model id at huggingface.co — copy the repo name precisely
- Pick a model that shows Inference Providers on its model page
- Update g4f in case the mapping endpoint handling changed
- List supported models via cls.get_models() and choose from those
Example fix
# before model = 'black-forest-labs/flux-dev-typo' # after model = 'black-forest-labs/FLUX.1-dev'
Defensive patterns
Strategy: validation
Validate before calling
supported = set(HuggingFaceMedia.get_models())
if model not in supported:
raise ValueError(f'{model} not served; choose from {sorted(supported)[:5]}...') Try / catch
from g4f.errors import ModelNotFoundError
try:
...
except ModelNotFoundError:
model = HuggingFaceMedia.get_models()[0]
... Prevention
- Validate model ids against get_models() before calling
- Copy model ids exactly from huggingface.co including casing
- Re-validate the model list after updating g4f or the HF catalog changes
When it happens
Trigger: Requesting a HuggingFaceMedia model id that does not exist or has no inference providers registered (get_mapping returns {} or only unsupported providers).
Common situations: Typo'd or outdated model id; model delisted from the inference router; new model not yet registered for inference; region/account restrictions removing all providers.
Related errors
- Model {model} not found
- Model '{_model}' is not supported by LMArena provider.
- Add a "api_key"
- Model is not supported: {model} in: {cls.__name__} task: {ta
- Provider '{item}' not found
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/4f21528c77e0166b.
Report an issue: GitHub.