{"record":{"id":"992b917c562e0010","repo":"xtekky/gpt4free","slug":"provider-not-found-provider-name-r","errorCode":null,"errorMessage":"Provider not found: {provider_name!r}","messagePattern":"Provider not found: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/providers/config_provider.py","lineNumber":458,"sourceCode":"# ---------------------------------------------------------------------------\n# Config-based provider\n# ---------------------------------------------------------------------------\n\n\ndef _resolve_provider(provider_name: str):\n    \"\"\"Resolve a provider name string to a provider class.\"\"\"\n    from .. import Provider\n    from ..Provider import ProviderUtils\n\n    if provider_name in ProviderUtils.convert:\n        return ProviderUtils.convert[provider_name]\n\n    # Try direct attribute lookup on the Provider module\n    provider = getattr(Provider, provider_name, None)\n    if provider is not None:\n        return provider\n\n    raise ValueError(f\"Provider not found: {provider_name!r}\")\n\n\nasync def _get_quota_cached(provider) -> Optional[dict]:\n    \"\"\"Return quota info for *provider*, using the cache when possible.\"\"\"\n    name = getattr(provider, \"__name__\", str(provider))\n    cached = QuotaCache.get(name)\n    if cached is not None:\n        return cached\n    if not hasattr(provider, \"get_quota\"):\n        return None\n    try:\n        quota = await provider.get_quota()\n        if quota is not None:\n            QuotaCache.set(name, quota)\n        return quota\n    except Exception as e:\n        debug.error(f\"config.yaml: get_quota failed for {name}:\", e)\n        return None","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/providers/config_provider.py#L440-L476","documentation":"ValueError from the config.yaml provider resolver: a provider name string could not be resolved to a provider class — it is absent from ProviderUtils.convert and not an attribute of the g4f.Provider module. The message echoes the offending name with repr() so whitespace/case errors are visible.","triggerScenarios":"A config.yaml entry lists provider: 'Openai' / 'SomeTypo' / a provider removed from g4f; the resolver looks it up in ProviderUtils.convert and getattr(Provider, name) and both miss.","commonSituations":"Typos or wrong casing in provider names; configs written for an older/newer g4f where the provider was renamed or dropped; trailing spaces or quotes issues from YAML; community providers not shipped in your install.","solutions":["Print available names — from g4f import Provider; print([n for n in dir(Provider) if not n.startswith('_')]) — and match your config to it exactly (case-sensitive).","Update g4f if the provider exists upstream but not in your installed version.","Remove or comment out the unknown provider entry in config.yaml.","Check for invisible whitespace in the YAML value (repr in the error message reveals it)."],"exampleFix":"# before (config.yaml)\nprovider: \"OpenAiChat \"\n\n# after\nprovider: \"OpenaiChat\"","handlingStrategy":"validation","validationCode":"from g4f import Provider\nfrom g4f.Provider import ProviderUtils\nunknown = [n for n in my_provider_names\n           if n not in ProviderUtils.convert and getattr(Provider, n, None) is None]\nif unknown:\n    raise ValueError(f'config.yaml references unknown providers: {unknown}')","typeGuard":"def provider_exists(name: str) -> bool:\n    from g4f import Provider\n    from g4f.Provider import ProviderUtils\n    return name in ProviderUtils.convert or getattr(Provider, name, None) is not None","tryCatchPattern":null,"preventionTips":["Validate provider names against the installed g4f at app startup.","Names are case-sensitive and must not have stray whitespace.","Re-validate config.yaml after every g4f upgrade."],"tags":["config","yaml","provider-resolution","typo","g4f"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}