BerriAI/litellm · error · ValueError
No provider mapping found for model {model}
Error message
No provider mapping found for model {model} What it means
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.
Source
Thrown at litellm/llms/huggingface/common_utils.py:88
Raises:
ValueError: If no provider mapping is found
HuggingFaceError: If the API request fails
"""
headers = {"Accept": "application/json"}
if os.getenv("HUGGINGFACE_API_KEY"):
headers["Authorization"] = f"Bearer {os.getenv('HUGGINGFACE_API_KEY')}"
path: Final = f"{HF_HUB_URL}/api/models/{model}"
params: Final = {"expand": ["inferenceProviderMapping"]}
try:
response: Final = httpx.get(path, headers=headers, params=params)
response.raise_for_status()
provider_mapping: Final = response.json().get("inferenceProviderMapping")
if provider_mapping is None:
raise ValueError(f"No provider mapping found for model {model}")
return provider_mapping
except httpx.HTTPError as e:
if hasattr(e, "response"):
status_code = getattr(e.response, "status_code", 500)
headers = getattr(e.response, "headers", {})
else:
status_code = 500
headers = {}
raise HuggingFaceError(
message=f"Failed to fetch provider mapping: {e}",
status_code=status_code,
headers=headers,
)
View on GitHub (pinned to 6c2dcb801b)
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.
Example fix
# before litellm.completion(model='hf/some-org/model-without-providers', messages=msgs) # ValueError: No provider mapping found for model some-org/model-without-providers # after — pick a deployed model or self-host litellm.completion(model='hf/meta-llama/Llama-3.1-8B-Instruct', messages=msgs) # or self-host: litellm.completion(model='hosted_vllm/some-org/model-without-providers', # api_base='http://my-vllm:8000', messages=msgs)
Defensive patterns
Strategy: validation
Validate before calling
import httpx
def has_inference_providers(model_id: str) -> bool:
r = httpx.get(f"https://huggingface.co/api/models/{model_id}",
params={"expand": ["inferenceProviderMapping"]}, timeout=10)
r.raise_for_status()
return bool(r.json().get("inferenceProviderMapping"))
if not has_inference_providers("some-org/some-model"):
raise ValueError("model has no inference providers — pick a deployed model or self-host") Try / catch
try:
litellm.completion(model="hf/org/model", messages=msgs)
except ValueError as e:
if "No provider mapping found" in str(e):
# permanent condition — switch model or self-host, do not retry
raise RuntimeError("model not served by any HF inference provider") from e
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to fetch provider mapping: {e}
- Error rendering template - {e}
- No chat template found
- Invalid task_type={task_type}. Expected one of={hf_tasks_emb
- sentence-similarity requires 2+ sentences
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/9a6d5b751e6d6d9d.
Report an issue: GitHub.