BerriAI/litellm · error · LiteLLMUnknownProvider
Unmapped LLM provider for this endpoint. You passed model=
Error message
Unmapped LLM provider for this endpoint. You passed model={model}, custom_llm_provider={custom_llm_provider}. Check supported provider and route: https://docs.litellm.ai/docs/providers What it means
litellm treats custom_llm_provider as a custom handler when it appears in litellm._custom_providers, then searches litellm.custom_provider_map for an entry {'provider': name, 'custom_handler': CustomLLM}. If no entry matches, LiteLLMUnknownProvider is raised from the image-generation endpoint. It means the provider name is known as custom but no handler instance was registered for it.
Solutions
- Register both pieces with identical strings: litellm.custom_provider_map.append({'provider': 'my_provider', 'custom_handler': MyHandler()}) and make sure 'my_provider' is in litellm._custom_providers (litellm.add_custom_provider on recent versions does both).
- Check exact case/spelling of the provider string you pass against the map entry.
- Ensure registration runs in every process that serves image calls (proxy startup hook), not just once at import in a single worker.
- Catch LiteLLMUnknownProvider from litellm.exceptions to surface a clear config error in your service.
Example fix
# before
litellm._custom_providers.append("acme_images")
resp = litellm.image_generation(model="acme/foo", prompt="a cat")
# LiteLLMUnknownProvider: Unmapped LLM provider ...
# after
from litellm.integrations.custom_logger import CustomLLM
class AcmeHandler(CustomLLM):
def image_generation(self, model, prompt, **kwargs):
...
litellm.custom_provider_map.append({"provider": "acme_images", "custom_handler": AcmeHandler()})
resp = litellm.image_generation(model="acme_images/foo", prompt="a cat") Defensive patterns
Strategy: validation
Validate before calling
import litellm
def custom_provider_registered(name: str) -> bool:
return any(
entry.get("provider") == name and entry.get("custom_handler") is not None
for entry in litellm.custom_provider_map
)
# before routing:
assert custom_provider_registered("acme"), "register {'provider': 'acme', 'custom_handler': ...} in litellm.custom_provider_map" Type guard
from litellm.integrations.custom_logger import CustomLLM
def handler_for(provider: str) -> CustomLLM | None:
for item in litellm.custom_provider_map:
if item.get("provider") == provider and isinstance(item.get("custom_handler"), CustomLLM):
return item["custom_handler"]
return None Try / catch
from litellm.exceptions import LiteLLMUnknownProvider
try:
resp = litellm.image_generation(model="acme/foo", prompt=p)
except LiteLLMUnknownProvider as e:
raise RuntimeError(f"custom provider not registered in this process: {e}") from e Prevention
- Centralize custom provider registration in one module imported by every entrypoint (API server, workers, CLI).
- Run registration in proxy startup hooks so all workers get the custom_provider_map.
- Assert handler_for(provider) is not None before dispatching to a custom provider.
- Never mutate litellm._custom_providers without the matching custom_provider_map entry.
When it happens
Trigger: Appending a name to litellm._custom_providers directly without adding the matching custom_provider_map entry; a case or spelling mismatch between the map's 'provider' string and the value passed as custom_llm_provider; calling image generation with a custom provider string that was never registered; registering the map after the call or in a different process (e.g. proxy worker) than the one that made _custom_providers contain the name.
Common situations: CustomLLM integrations where the user updates _custom_providers for routing but forgets litellm.custom_provider_map.append(...); proxy deployments where registration code runs in the main process only and a background worker handles the image request; refactors renaming the provider string in one place but not the other.
Related errors
- Unmapped LLM provider for this endpoint. You passed model=
- completion_response must be of type ImageResponse for…
- Error parsing OpenRouter response
- Error transforming OpenRouter image generation response
- image generation config is not supported for
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/84b14a87a35d4da5.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/images/main.py:507
prompt=prompt,
timeout=timeout,
logging_obj=litellm_logging_obj,
optional_params=optional_params,
model_response=model_response,
aimg_generation=aimg_generation,
client=client,
api_base=api_base,
api_key=api_key,
)
elif custom_llm_provider in litellm._custom_providers: # Assume custom LLM provider
# Get the Custom Handler
custom_handler: CustomLLM | None = None
for item in litellm.custom_provider_map:
if item["provider"] == custom_llm_provider:
custom_handler = item["custom_handler"]
if custom_handler is None:
raise LiteLLMUnknownProvider(model=model, custom_llm_provider=custom_llm_provider)
## ROUTE LLM CALL ##
if aimg_generation is True:
async_custom_client: AsyncHTTPHandler | None = None
if client is not None and isinstance(client, AsyncHTTPHandler):
async_custom_client = client
## CALL FUNCTION
model_response = custom_handler.aimage_generation(
model=model,
prompt=prompt,
api_key=api_key,
api_base=api_base,
model_response=model_response,
optional_params=optional_params,
logging_obj=litellm_logging_obj,
timeout=timeout,
client=async_custom_client,View on GitHub (pinned to 77b7c6c40c)