{"record":{"id":"84b14a87a35d4da5","repo":"BerriAI/litellm","slug":"unmapped-llm-provider-for-this-endpoint-you-passe","errorCode":null,"errorMessage":"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","messagePattern":"Unmapped LLM provider for this endpoint\\. You passed model=(.+?), custom_llm_provider=(.+?)\\. Check supported provider and route: https://docs\\.litellm\\.ai/docs/providers","errorType":"validation","errorClass":"LiteLLMUnknownProvider","httpStatus":400,"severity":"error","filePath":"litellm/images/main.py","lineNumber":507,"sourceCode":"                prompt=prompt,\n                timeout=timeout,\n                logging_obj=litellm_logging_obj,\n                optional_params=optional_params,\n                model_response=model_response,\n                aimg_generation=aimg_generation,\n                client=client,\n                api_base=api_base,\n                api_key=api_key,\n            )\n        elif custom_llm_provider in litellm._custom_providers:  # Assume custom LLM provider\n            # Get the Custom Handler\n            custom_handler: CustomLLM | None = None\n            for item in litellm.custom_provider_map:\n                if item[\"provider\"] == custom_llm_provider:\n                    custom_handler = item[\"custom_handler\"]\n\n            if custom_handler is None:\n                raise LiteLLMUnknownProvider(model=model, custom_llm_provider=custom_llm_provider)\n\n            ## ROUTE LLM CALL ##\n            if aimg_generation is True:\n                async_custom_client: AsyncHTTPHandler | None = None\n                if client is not None and isinstance(client, AsyncHTTPHandler):\n                    async_custom_client = client\n\n                ## CALL FUNCTION\n                model_response = custom_handler.aimage_generation(\n                    model=model,\n                    prompt=prompt,\n                    api_key=api_key,\n                    api_base=api_base,\n                    model_response=model_response,\n                    optional_params=optional_params,\n                    logging_obj=litellm_logging_obj,\n                    timeout=timeout,\n                    client=async_custom_client,","sourceCodeStart":489,"sourceCodeEnd":525,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/images/main.py#L489-L525","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nlitellm._custom_providers.append(\"acme_images\")\nresp = litellm.image_generation(model=\"acme/foo\", prompt=\"a cat\")\n# LiteLLMUnknownProvider: Unmapped LLM provider ...\n\n# after\nfrom litellm.integrations.custom_logger import CustomLLM\n\nclass AcmeHandler(CustomLLM):\n    def image_generation(self, model, prompt, **kwargs):\n        ...\n\nlitellm.custom_provider_map.append({\"provider\": \"acme_images\", \"custom_handler\": AcmeHandler()})\nresp = litellm.image_generation(model=\"acme_images/foo\", prompt=\"a cat\")","handlingStrategy":"validation","validationCode":"import litellm\n\ndef custom_provider_registered(name: str) -> bool:\n    return any(\n        entry.get(\"provider\") == name and entry.get(\"custom_handler\") is not None\n        for entry in litellm.custom_provider_map\n    )\n\n# before routing:\nassert custom_provider_registered(\"acme\"), \"register {'provider': 'acme', 'custom_handler': ...} in litellm.custom_provider_map\"","typeGuard":"from litellm.integrations.custom_logger import CustomLLM\n\ndef handler_for(provider: str) -> CustomLLM | None:\n    for item in litellm.custom_provider_map:\n        if item.get(\"provider\") == provider and isinstance(item.get(\"custom_handler\"), CustomLLM):\n            return item[\"custom_handler\"]\n    return None","tryCatchPattern":"from litellm.exceptions import LiteLLMUnknownProvider\n\ntry:\n    resp = litellm.image_generation(model=\"acme/foo\", prompt=p)\nexcept LiteLLMUnknownProvider as e:\n    raise RuntimeError(f\"custom provider not registered in this process: {e}\") from e","preventionTips":["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."],"tags":["litellm","image-generation","custom-provider","provider-registration"],"backgroundTag":"unknown-provider","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}