xtekky/gpt4free · error · NotImplementedError
No base_url or backup_url specified.
Error message
No base_url or backup_url specified.
What it means
Error "No base_url or backup_url specified." thrown in xtekky/gpt4free.
Source
Thrown at g4f/Provider/template/OpenaiTemplate.py:106
) -> list[str]:
if not cls.models:
try:
if api_key is None and cls.api_key is not None:
api_key = cls.api_key
if (
not api_key
or AppConfig.disable_custom_api_key
or not cls.is_provider_api_key(api_key)
):
from ...tools.run_tools import AuthManager
api_key = AuthManager.load_api_key(cls) or api_key
if base_url is None:
base_url = cls.base_url
if not cls.is_provider_api_key(api_key):
base_url = cls.backup_url
if base_url is None:
raise NotImplementedError(
"No base_url or backup_url specified."
)
if base_url.startswith(SPACE_URL) and not api_key:
api_key = AppConfig.g4f_space_api_key
elif cls.models_needs_auth and not api_key:
raise MissingAuthError("API key is required.")
elif (
not base_url.startswith(SPACE_URL)
and api_key
and (api_key.startswith("g4f_") or api_key.startswith("gfs_"))
):
raise ValueError("Invalid API key for the specified base_url.")
response = requests.get(
f"{base_url}/models",
headers=cls.get_headers(False, api_key),
verify=cls.ssl,
timeout=timeout,View on GitHub (pinned to 973504e177)
Solutions
- Set base_url (or backup_url) on the provider or via its environment variable before making requests.
When it happens
Trigger: Thrown at g4f/Provider/template/OpenaiTemplate.py:106 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/ba9e4afe94f727f8.
Report an issue: GitHub.