{"record":{"id":"4f21528c77e0166b","repo":"xtekky/gpt4free","slug":"model-is-not-supported-model-in-cls-name","errorCode":null,"errorMessage":"Model is not supported: {model} in: {cls.__name__}","messagePattern":"Model is not supported: (.+?) in: (.+?)","errorType":"exception","errorClass":"ModelNotFoundError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/hf/HuggingFaceMedia.py","lineNumber":163,"sourceCode":"        if model and \":\" in model:\n            model, selected_provider = model.split(\":\", 1)\n        elif not model:\n            model = cls.get_models()[0]\n        prompt = format_media_prompt(messages, prompt)\n        provider_mapping = await cls.get_mapping(model, api_key)\n        headers = {\n            \"Accept-Encoding\": \"gzip, deflate\",\n            \"Content-Type\": \"application/json\",\n            \"Prefer\": \"wait\",\n        }\n        new_mapping = {\n            \"hf-free\" if key == \"hf-inference\" else key: value\n            for key, value in provider_mapping.items()\n            if key in [\"replicate\", \"together\", \"hf-inference\"]\n        }\n        provider_mapping = {**new_mapping, **provider_mapping}\n        if not provider_mapping:\n            raise ModelNotFoundError(\n                f\"Model is not supported: {model} in: {cls.__name__}\"\n            )\n\n        async def generate(extra_body: dict, aspect_ratio: str = None):\n            last_response = None\n            for provider_key, provider in provider_mapping.items():\n                if selected_provider is not None and selected_provider != provider_key:\n                    continue\n                provider_info = ProviderInfo(\n                    **{\n                        **cls.get_dict(),\n                        \"label\": f\"HuggingFace ({provider_key})\",\n                        \"url\": f\"{cls.url}/{model}\",\n                    }\n                )\n\n                base_url = f\"https://router.huggingface.co/{provider_key}\"\n                task = provider[\"task\"]","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/hf/HuggingFaceMedia.py#L145-L181","documentation":"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.","triggerScenarios":"Requesting a HuggingFaceMedia model id that does not exist or has no inference providers registered (get_mapping returns {} or only unsupported providers).","commonSituations":"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.","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"],"exampleFix":"# before\nmodel = 'black-forest-labs/flux-dev-typo'\n# after\nmodel = 'black-forest-labs/FLUX.1-dev'","handlingStrategy":"validation","validationCode":"supported = set(HuggingFaceMedia.get_models())\nif model not in supported:\n    raise ValueError(f'{model} not served; choose from {sorted(supported)[:5]}...')","typeGuard":null,"tryCatchPattern":"from g4f.errors import ModelNotFoundError\ntry:\n    ...\nexcept ModelNotFoundError:\n    model = HuggingFaceMedia.get_models()[0]\n    ...","preventionTips":["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"],"tags":["huggingface","model-not-found","media-generation","validation"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}