{"record":{"id":"178970c3582659c8","repo":"xtekky/gpt4free","slug":"model-is-not-supported-model-in-cls-name-178970","errorCode":null,"errorMessage":"Model is not supported: {model} in: {cls.__name__} task: {task}","messagePattern":"Model is not supported: (.+?) in: (.+?) task: (.+?)","errorType":"exception","errorClass":"ModelNotFoundError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/hf/HuggingFaceMedia.py","lineNumber":184,"sourceCode":"\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\"]\n                provider_id = provider[\"providerId\"]\n                if task not in cls.tasks:\n                    raise ModelNotFoundError(\n                        f\"Model is not supported: {model} in: {cls.__name__} task: {task}\"\n                    )\n\n                if aspect_ratio is None:\n                    aspect_ratio = \"1:1\" if task == \"text-to-image\" else \"16:9\"\n                extra_body_image = use_aspect_ratio(\n                    {\n                        **extra_body,\n                        \"height\": height,\n                        \"width\": width,\n                    },\n                    aspect_ratio,\n                )\n                extra_body_video = {}\n                if task == \"text-to-video\" and provider_key != \"novita\":\n                    extra_body_video = {\n                        \"num_inference_steps\": 20,\n                        \"resolution\": resolution,","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/hf/HuggingFaceMedia.py#L166-L202","documentation":"Raised inside HuggingFaceMedia's generate() loop when a mapped provider's returned \"task\" field (e.g. text-to-image, text-to-video) is not in the provider class's supported tasks set. ModelNotFoundError with the task appended: the model exists on the router, but this g4f provider cannot handle the task type it is served under.","triggerScenarios":"A provider entry in the router mapping reports a task (e.g. text-to-video on a model you called as an image model, or a new task type) that HuggingFaceMedia.tasks does not include.","commonSituations":"Calling an image model whose only provider serves a different task; HuggingFace adds a new task label (e.g. image-to-video) unsupported by the installed g4f version.","solutions":["Read the task in the message — use a model/provider combination whose task matches what you want","Update g4f to gain support for newly added router task types","Select the provider explicitly via 'model:provider_key' syntax to skip incompatible entries","Choose a different model that is served under a supported task"],"exampleFix":"# before\nmodel = 'some-model'  # only served as text-to-video\n# after\nmodel = 'some-model:hf-inference'  # pick a provider entry with a supported task","handlingStrategy":"validation","validationCode":"mapping = await HuggingFaceMedia.get_mapping(model, api_key)\ntasks = {p['task'] for p in mapping.values()}\nif not tasks & set(HuggingFaceMedia.tasks):\n    raise ValueError(f'{model} only served under tasks {tasks}')","typeGuard":null,"tryCatchPattern":"from g4f.errors import ModelNotFoundError\ntry:\n    ...\nexcept ModelNotFoundError as e:\n    if 'task:' in str(e):\n        model = pick_model_for_task(HuggingFaceMedia.get_models(), wanted_task)\n        ...","preventionTips":["Match the model to the media type you want (image model for images, video model for video)","Use 'model:provider' to pin an entry with the right task","Update g4f to gain newly supported router task labels"],"tags":["huggingface","model-not-supported","task-mismatch","media-generation"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}