BerriAI/litellm · error · ValueError

Provider not found

Error message

Provider {custom_llm_provider} not found

What it means

Raised in _get_openai_compatible_provider_info() for models like '<slug>/model' where <slug> is a JSON-defined OpenAI-like provider loaded from litellm/llms/openai_like/providers.json via JSONProviderRegistry. exists(slug) returned True but get(slug) returned None — an inconsistent registry state. With the shipped registry this is close to impossible (values are never None), so hitting it means providers.json failed to load (the loader swallows errors with only a warning), was hand-edited/corrupted, or a custom registry subclass changed get().

Solutions

  1. Validate the registry at startup: JSONProviderRegistry.get(slug) must return a SimpleProviderConfig with base_url and api_key_env before you call that model.
  2. Restore the stock providers.json (reinstall litellm: pip install --force-reinstall litellm) or fix your edited copy so every slug maps to a valid config.
  3. Pin a known-good litellm version if this appeared after an upgrade.
  4. If the file is intact, report the bug upstream with your litellm version and model string.

Example fix

# before
litellm.completion(model='my-json-provider/llama-3')  # ValueError: Provider my-json-provider not found

# after
from litellm.llms.openai_like.json_loader import JSONProviderRegistry
cfg = JSONProviderRegistry.get('my-json-provider')
assert cfg is not None and cfg.base_url and cfg.api_key_env, 'fix providers.json entry'
litellm.completion(model='my-json-provider/llama-3')
Defensive patterns

Strategy: validation

Validate before calling

from litellm.llms.openai_like.json_loader import JSONProviderRegistry

slug = model.split('/', 1)[0]
cfg = JSONProviderRegistry.get(slug)
if cfg is None or not getattr(cfg, 'base_url', None):
    raise RuntimeError(f'JSON provider {slug!r} is not properly registered; fix providers.json')
resp = litellm.completion(model=model)

Type guard

from litellm.llms.openai_like.json_loader import SimpleProviderConfig

def is_registered_json_provider(slug: str) -> bool:
    cfg = JSONProviderRegistry.get(slug)
    return isinstance(cfg, SimpleProviderConfig) and bool(cfg.base_url)

Try / catch

try:
    resp = litellm.completion(model='my-json-provider/llama-3')
except ValueError as e:
    if 'not found' in str(e):
        # registry inconsistent: reinstall litellm or repair providers.json
        raise
    raise

Prevention

When it happens

Trigger: litellm.completion(model='<json-provider-slug>/some-model') after the providers.json file was modified, partially loaded due to a JSON parse error, or replaced by a fork; also possible in cut-down deployments that strip .json data files from the wheel.

Common situations: Editing providers.json to add a provider and breaking its structure; Docker images that exclude JSON data files; downgrades/upgrades that leave a stale registry; packaging tools (pyinstaller-style) omitting data files.

Related errors


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

Appendix: source

Thrown at litellm/litellm_core_utils/get_llm_provider_logic.py:539

    Returns:
        Tuple[str, str, Optional[str], Optional[str]]:
            model: str
            custom_llm_provider: str
            dynamic_api_key: Optional[str]
            api_base: Optional[str]
    """

    custom_llm_provider = model.split("/", 1)[0]
    model = model.split("/", 1)[1]

    # Check JSON providers FIRST (before hardcoded ones)
    from litellm.llms.openai_like.dynamic_config import create_config_class
    from litellm.llms.openai_like.json_loader import JSONProviderRegistry

    if JSONProviderRegistry.exists(custom_llm_provider):
        provider_config: Final = JSONProviderRegistry.get(custom_llm_provider)
        if provider_config is None:
            raise ValueError(f"Provider {custom_llm_provider} not found")
        config_class: Final = create_config_class(provider_config)
        api_base, dynamic_api_key = config_class()._get_openai_compatible_provider_info(api_base, api_key)
        return model, custom_llm_provider, dynamic_api_key, api_base

    if custom_llm_provider == "perplexity":
        # perplexity is openai compatible, we just need to set this to custom_openai and have the api_base be https://api.perplexity.ai
        (
            api_base,
            dynamic_api_key,
        ) = litellm.PerplexityChatConfig()._get_openai_compatible_provider_info(api_base, api_key)
    elif custom_llm_provider == "aiohttp_openai":
        return model, "aiohttp_openai", api_key, api_base
    elif custom_llm_provider == "anyscale":
        # anyscale is openai compatible, we just need to set this to custom_openai and have the api_base be https://api.endpoints.anyscale.com/v1
        api_base = api_base or get_secret_str("ANYSCALE_API_BASE") or "https://api.endpoints.anyscale.com/v1"
        dynamic_api_key = api_key or get_secret_str("ANYSCALE_API_KEY")
    elif custom_llm_provider == "deepinfra":
        (

View on GitHub (pinned to 77b7c6c40c)