xtekky/gpt4free · error · NotImplementedError

No default model specified.

Error message

No default model specified.

What it means

Error "No default model specified." thrown in xtekky/gpt4free.

Source

Thrown at g4f/Provider/template/OpenaiTemplate.py:54

    @classmethod
    async def get_quota(cls, api_key: Optional[str] = None, **kwargs) -> dict:
        """Get the quota information for the API key."""
        if not api_key:
            from ...tools.run_tools import AuthManager

            api_key = AuthManager.load_api_key(cls)
        if api_key and cls.models_needs_auth and cls.quota_url is None:
            cls.quota_url = f"{cls.base_url}/models"
        if cls.quota_url is None:
            if cls.backup_url is not None:
                cls.quota_url = f"{cls.backup_url}/chat/completions"
        if cls.quota_url is not None:
            return await super().get_quota(api_key=api_key, **kwargs)
        if not api_key and cls.needs_auth:
            raise MissingAuthError("API key is required.")
        if not cls.default_model:
            raise NotImplementedError("No default model specified.")
        return await cls.test_api_key(api_key)

    @classmethod
    async def test_api_key(cls, api_key: str):
        if api_key in cls._checked_api_keys:
            return cls._checked_api_keys[api_key]
        url = f"{cls.base_url}/chat/completions"
        headers = {"authorization": f"Bearer {api_key}"} if api_key else {}
        json_data = {
            "model": cls.default_model,
            "messages": [{"role": "user", "content": "say only okay"}],
            "max_tokens": 1,
        }
        async with StreamSession() as session:
            async with session.post(url, headers=headers, json=json_data) as response:
                await raise_for_status(response)
                result = await response.json()
                cls._checked_api_keys[api_key] = result

View on GitHub (pinned to 973504e177)

Solutions

  1. Define a default model on the provider class or pass an explicit model argument.

When it happens

Trigger: Thrown at g4f/Provider/template/OpenaiTemplate.py:54 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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