xtekky/gpt4free · warning · NotImplementedError
{cls.__name__} does not implement get_quota method
Error message
{cls.__name__} does not implement get_quota method What it means
Raised by AsyncGeneratorProvider.get_quota when the class attribute quota_url is None — the default on the base class. The generic implementation can only fetch quota from a documented endpoint; providers that never define quota_url cannot support it, so the base method refuses rather than guessing.
Source
Thrown at g4f/providers/base_provider.py:310
str: The created result as a string.
"""
raise NotImplementedError()
class AsyncGeneratorProvider(AbstractProvider):
"""
Provides asynchronous generator functionality for streaming results.
"""
supports_stream = True
use_stream_timeout = True
quota_url = None
@classmethod
async def get_quota(cls, api_key: Optional[str] = None, **kwargs) -> dict:
"""Get the quota information for the API key."""
if cls.quota_url is None:
raise NotImplementedError(
f"{cls.__name__} does not implement get_quota method"
)
if not api_key and cls.needs_auth:
raise MissingAuthError("API key is required.")
headers = {"authorization": f"Bearer {api_key}"} if api_key else {}
async with ClientSession() as session:
async with session.get(cls.quota_url, headers=headers) as response:
await raise_for_status(response)
return await response.json()
@staticmethod
@abstractmethod
async def create_async_generator(
model: str, messages: Messages, **kwargs
) -> AsyncResult:
"""
Abstract method for creating an asynchronous generator.
View on GitHub (pinned to 973504e177)
Solutions
- Skip providers without an endpoint first: if Provider.quota_url is None: continue
- If the upstream service has a real quota API, set quota_url on your subclass and get_quota will fetch it
- Catch NotImplementedError around the call as a fallback guard
Example fix
# before
quota = await provider.get_quota(api_key)
# after
if provider.quota_url is None:
quota = None
else:
quota = await provider.get_quota(api_key) Defensive patterns
Strategy: type-guard
Validate before calling
if provider.quota_url is None:
return None # provider cannot report quota; skip the call
return await provider.get_quota(api_key) Type guard
def supports_quota(provider: type) -> bool:
return getattr(provider, "quota_url", None) is not None Try / catch
try:
quota = await provider.get_quota(api_key=key)
except NotImplementedError:
quota = None # treat as 'quota unknown' rather than an error Prevention
- Filter provider lists by quota_url before calling get_quota
- Treat NotImplementedError here as an expected 'unsupported' signal, not a bug
When it happens
Trigger: await SomeProvider.get_quota(api_key=...) where SomeProvider (or the base AsyncGeneratorProvider) leaves quota_url unset (None).
Common situations: Quota-checking UIs iterating over all installed providers and calling get_quota indiscriminately; custom PA providers that forgot to define quota_url; free/scraping providers that have no quota endpoint at all.
Related errors
- {provider.__name__} does not implement an async method
- {provider.__name__} does not implement a create method
- API key is required.
- No response
- {data['code']}:{data['details']}
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/507cc7bf2d515118.
Report an issue: GitHub.