{"record":{"id":"9a6d5b751e6d6d9d","repo":"BerriAI/litellm","slug":"no-provider-mapping-found-for-model-model","errorCode":null,"errorMessage":"No provider mapping found for model {model}","messagePattern":"No provider mapping found for model (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/huggingface/common_utils.py","lineNumber":88,"sourceCode":"\n    Raises:\n        ValueError: If no provider mapping is found\n        HuggingFaceError: If the API request fails\n    \"\"\"\n    headers = {\"Accept\": \"application/json\"}\n    if os.getenv(\"HUGGINGFACE_API_KEY\"):\n        headers[\"Authorization\"] = f\"Bearer {os.getenv('HUGGINGFACE_API_KEY')}\"\n\n    path: Final = f\"{HF_HUB_URL}/api/models/{model}\"\n    params: Final = {\"expand\": [\"inferenceProviderMapping\"]}\n\n    try:\n        response: Final = httpx.get(path, headers=headers, params=params)\n        response.raise_for_status()\n        provider_mapping: Final = response.json().get(\"inferenceProviderMapping\")\n\n        if provider_mapping is None:\n            raise ValueError(f\"No provider mapping found for model {model}\")\n\n        return provider_mapping\n    except httpx.HTTPError as e:\n        if hasattr(e, \"response\"):\n            status_code = getattr(e.response, \"status_code\", 500)\n            headers = getattr(e.response, \"headers\", {})\n        else:\n            status_code = 500\n            headers = {}\n        raise HuggingFaceError(\n            message=f\"Failed to fetch provider mapping: {e}\",\n            status_code=status_code,\n            headers=headers,\n        )\n","sourceCodeStart":70,"sourceCodeEnd":103,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/huggingface/common_utils.py#L70-L103","documentation":"_fetch_inference_provider_mapping() GETs https://huggingface.co/api/models/<model> with expand=inferenceProviderMapping; if the returned JSON has no 'inferenceProviderMapping' key, it raises ValueError('No provider mapping found for model <model>'). That means the Hub knows the repo but exposes no inference providers for it — the model cannot be called via HF serverless routing through this code path.","triggerScenarios":"Requesting an 'hf/...' model that is not available for serverless inference: non-generative repos (datasets, spaces, demos), gated/private models your token cannot expand, or models with all providers disabled.","commonSituations":"Using a repository id that is a Space or dataset rather than a model; a brand-new model whose provider rollout has not happened; private/gated model without HUGGINGFACE_API_KEY set; renaming/deletion of the repo.","solutions":["Verify the repo is a model with inference providers: open the model page and check the Inference Providers section, or curl the API URL above","If the model is gated/private, set HUGGINGFACE_API_KEY so the Hub returns the mapping","Choose a model that lists inference providers, or deploy it yourself and pass api_base (an Inference Endpoint / TEI / TGI URL) to skip Hub routing","Double-check the model id spelling (owner/repo)"],"exampleFix":"# before\nlitellm.completion(model=\"hf/some-org/model-without-providers\", messages=msgs)\n\n# after — self-host and pass api_base to bypass Hub routing\nlitellm.completion(\n    model=\"hf/some-org/model-without-providers\",\n    api_base=\"https://xxxx.endpoints.huggingface.cloud/v1\",\n    messages=msgs,\n)","handlingStrategy":"validation","validationCode":"import httpx, os\n\ndef hf_has_inference(model_id: str) -> bool:\n    headers = {\"Authorization\": f\"Bearer {os.getenv('HUGGINGFACE_API_KEY', '')}\"} if os.getenv(\"HUGGINGFACE_API_KEY\") else {}\n    r = httpx.get(\n        f\"https://huggingface.co/api/models/{model_id}\",\n        params={\"expand\": [\"inferenceProviderMapping\"]}, headers=headers,\n    )\n    return r.status_code == 200 and r.json().get(\"inferenceProviderMapping\") is not None","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Curate an allowlist of known-good hf model ids instead of accepting arbitrary user-supplied ids","Set HUGGINGFACE_API_KEY so gated/private models resolve their mapping","For models without serverless providers, deploy an endpoint and call it with api_base"],"tags":["huggingface","model-discovery","inference-providers","litellm"],"backgroundTag":"model-not-found","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}