BerriAI/litellm · error · LiteLLMUnknownProvider

Unmapped LLM provider for this endpoint. You passed model={m

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

LiteLLMUnknownProvider raised in _complete_custom_providers when custom_llm_provider does not match any entry in litellm.custom_provider_map. This branch handles providers litellm treats as user-registered custom handlers, so an unmatched name means nothing is registered to serve the model.

Source

Thrown at litellm/main.py:4760

    custom_prompt_dict: Final = ctx.custom_prompt_dict
    headers = ctx.headers
    litellm_params: Final = ctx.litellm_params
    logger_fn: Final = ctx.logger_fn
    logging: Final = ctx.logging
    messages: Final = ctx.messages
    model: Final = ctx.model
    model_response: Final = ctx.model_response
    optional_params: Final = ctx.optional_params
    stream: Final = ctx.stream
    timeout: Final = ctx.timeout

    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 ##
    handler_fn: Final = custom_chat_llm_router(async_fn=acompletion, stream=stream, custom_llm=custom_handler)

    headers = headers or litellm.headers or {}

    ## CALL FUNCTION
    response: Final = handler_fn(
        model=model,
        messages=messages,
        headers=headers,
        model_response=model_response,
        print_verbose=print_verbose,
        api_key=api_key,
        api_base=api_base,
        acompletion=acompletion,
        logging_obj=logging,
        optional_params=optional_params,

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Register the handler before calling: litellm.custom_provider_map.append({'provider': 'my_llm', 'custom_handler': MyCustomLLM()})
  2. Check exact string equality (case-sensitive) between the provider in the model string and the map entry
  3. If you just want an OpenAI-compatible endpoint, use model='openai/<model>' with api_base and skip custom providers entirely
  4. Move registration to import time / app startup so every worker registers before serving traffic

Example fix

# before
litellm.completion(model='acme-turbo/gpt', messages=m)  # LiteLLMUnknownProvider

# after
from litellm.integrations.custom_logger import CustomLLM
class AcmeHandler(CustomLLM):
    def completion(self, **kwargs): ...
litellm.custom_provider_map.append({'provider': 'acme-turbo', 'custom_handler': AcmeHandler()})
resp = litellm.completion(model='acme-turbo/gpt', messages=m)
Defensive patterns

Strategy: validation

Validate before calling

providers = {entry['provider'] for entry in litellm.custom_provider_map}
if custom_llm_provider not in providers:
    raise SystemExit(f'{custom_llm_provider!r} not registered in litellm.custom_provider_map')

Type guard

def provider_registered(provider: str, provider_map: list[dict]) -> bool:
    return any(entry.get('provider') == provider for entry in provider_map)

Try / catch

from litellm.exceptions import LiteLLMUnknownProvider
try:
    resp = litellm.completion(model='acme-turbo/gpt', messages=m)
except LiteLLMUnknownProvider as e:
    raise RuntimeError('register the custom handler before calling this model') from e

Prevention

When it happens

Trigger: Passing custom_llm_provider='my_llm' (or model='my_llm/...') without ever appending {'provider': 'my_llm', 'custom_handler': MyHandler()} to litellm.custom_provider_map; or a typo/case mismatch between the model prefix and the registered provider key.

Common situations: Custom handler registered in one process/service but the call happens in another (worker, notebook) where registration never ran; renaming the handler and forgetting the map; team code copying the call but not the registration lines.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/4e8acf2656eb1226. Report an issue: GitHub.