xtekky/gpt4free · error · NotImplementedError

has no supported create method

Error message

{provider_name} has no supported create method

What it means

NotImplementedError raised in config_provider's dispatch loop: the resolved provider class exposes neither create_async_generator nor create_completion, so there is no way to call it. It flags provider classes that are abstract helpers, base classes, or pure utility classes being listed directly in config.yaml.

Solutions

  1. Replace the entry with a concrete provider that implements create_async_generator or create_completion (most working providers do).
  2. List available working providers via g4f.Provider and pick one whose needs_auth/working flags are set.
  3. Update g4f in case the named provider was recently fixed to implement a create method.
  4. Remove the entry — other providers in the chain will still be tried (this error is caught per-provider, but the entry never succeeds).

Example fix

# before (config.yaml)
providers:
  - provider: "BaseProvider"

# after
providers:
  - provider: "OpenaiChat"
Defensive patterns

Strategy: validation

Validate before calling

def is_callable_provider(p) -> bool:
    return hasattr(p, 'create_async_generator') or hasattr(p, 'create_completion')

bad = [n for n, p in resolved_providers.items() if not is_callable_provider(p)]
if bad:
    raise ValueError(f'providers without a create method: {bad}')

Type guard

def is_callable_provider(p) -> bool:
    return hasattr(p, 'create_async_generator') or hasattr(p, 'create_completion')

Prevention

When it happens

Trigger: A config.yaml entry points at a class like a base provider, an ignored/deprecated stub, or a helper with only get_quota — the dispatch checks hasattr for both create methods and both fail.

Common situations: Listing base or internal provider names (e.g. AsyncGeneratorProvider itself, or an 'Ignored' provider) in config.yaml; g4f refactors that strip create methods from a provider while configs still reference it.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/f9ab72869c6ed318. Report an issue: GitHub.

Appendix: source

Thrown at g4f/providers/config_provider.py:578

            )
            if not current_api_key or AppConfig.disable_custom_api_key:
                current_api_key = AuthManager.load_api_key(provider)
            if current_api_key:
                extra_body["api_key"] = current_api_key

            try:
                if hasattr(provider, "create_async_generator"):
                    async for chunk in provider.create_async_generator(
                        target_model, messages, **extra_body
                    ):
                        yield chunk
                elif hasattr(provider, "create_completion"):
                    for chunk in provider.create_completion(
                        target_model, messages, **extra_body
                    ):
                        yield chunk
                else:
                    raise NotImplementedError(
                        f"{provider_name} has no supported create method"
                    )
                debug.log(f"config.yaml: {provider_name} succeeded for model {model!r}")
                return  # Success
            except Exception as e:
                # On rate-limit errors invalidate the quota cache
                from ..errors import RateLimitError

                if isinstance(e, RateLimitError) or "429" in str(e):
                    debug.log(
                        f"config.yaml: Rate-limited by {provider_name}, "
                        "invalidating quota cache"
                    )
                    QuotaCache.invalidate(provider_name)

                ErrorCounter.increment(provider_name)
                last_exception = e
                debug.error(f"config.yaml: {provider_name} failed:", e)

View on GitHub (pinned to 973504e177)