{"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":"http","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/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/huggingface/common_utils.py#L70-L103","documentation":"Raised in _fetch_inference_provider_mapping (litellm/llms/huggingface/common_utils.py) when the HF Hub API responds successfully for /api/models/<model> but the returned JSON has no inferenceProviderMapping field. This means the model exists on the Hub but has no inference-provider deployment mapping, so LiteLLM cannot resolve where to send the request.","triggerScenarios":"Requesting a model that has no Inference Providers enabled — gated/private models without provider deployment, freshly uploaded models not yet deployed, or datasets/spaces ids mistakenly used as model ids. The Hub returns 200 with metadata lacking inferenceProviderMapping.","commonSituations":"Using a niche or newly published model no provider hosts yet; model id typo that still resolves to some Hub object (e.g. wrong repo type); relying on a model whose provider deployments were removed after a provider partnership ended.","solutions":["Open the model page on huggingface.co and check the Inference Providers tab — if empty, no provider serves it; pick a model that is deployed (or the same model under an org that deployed it).","If it must be this model, self-host it (vLLM/TEI) and call it via hosted_vllm/custom_openai with api_base, or use a provider that hosts it.","Double-check the model id (org/name spelling) and that it is a model repo, not a dataset/space.","If the model should have providers (per the UI), it may be caching — retry after a short delay or verify with the expand=inferenceProviderMapping API call by hand."],"exampleFix":"# before\nlitellm.completion(model='hf/some-org/model-without-providers', messages=msgs)\n# ValueError: No provider mapping found for model some-org/model-without-providers\n\n# after — pick a deployed model or self-host\nlitellm.completion(model='hf/meta-llama/Llama-3.1-8B-Instruct', messages=msgs)\n# or self-host: litellm.completion(model='hosted_vllm/some-org/model-without-providers',\n#                                 api_base='http://my-vllm:8000', messages=msgs)\n","handlingStrategy":"validation","validationCode":"import httpx\n\ndef has_inference_providers(model_id: str) -> bool:\n    r = httpx.get(f\"https://huggingface.co/api/models/{model_id}\",\n                  params={\"expand\": [\"inferenceProviderMapping\"]}, timeout=10)\n    r.raise_for_status()\n    return bool(r.json().get(\"inferenceProviderMapping\"))\n\nif not has_inference_providers(\"some-org/some-model\"):\n    raise ValueError(\"model has no inference providers — pick a deployed model or self-host\")","typeGuard":null,"tryCatchPattern":"try:\n    litellm.completion(model=\"hf/org/model\", messages=msgs)\nexcept ValueError as e:\n    if \"No provider mapping found\" in str(e):\n        # permanent condition — switch model or self-host, do not retry\n        raise RuntimeError(\"model not served by any HF inference provider\") from e\n    raise","preventionTips":["Curate your model list against models that show Inference Providers on their Hub page.","For critical flows, self-host the model and call it via hosted_vllm/custom_openai with api_base instead of depending on Hub availability."],"tags":["huggingface","inference-providers","model-availability","hub-api"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}