xtekky/gpt4free · error · HTTPException
Incorrect username or password
Error message
Incorrect username or password
What it means
Error "Incorrect username or password" thrown in xtekky/gpt4free.
Source
Thrown at g4f/api/__init__.py:547
class Api:
def __init__(self, app: FastAPI) -> None:
self.app = app
self.client = AsyncClient()
self.get_g4f_api_key = APIKeyHeader(name="g4f-api-key")
self.conversations: dict[str, dict[str, BaseConversation]] = {}
security = HTTPBearer(auto_error=False)
basic_security = HTTPBasic()
async def get_username(self, request: Request) -> str:
credentials = await self.basic_security(request)
current_password_bytes = credentials.password.encode()
is_correct_password = secrets.compare_digest(
current_password_bytes, AppConfig.g4f_api_key.encode()
)
if not is_correct_password:
raise HTTPException(
status_code=HTTP_401_UNAUTHORIZED,
detail="Incorrect username or password",
headers={"WWW-Authenticate": "Basic"},
)
return credentials.username
def register_authorization(self):
if AppConfig.g4f_api_key:
print(
"Register authentication key:",
"".join(["*" for _ in range(len(AppConfig.g4f_api_key))]),
)
if has_crypto:
private_key, _ = create_or_read_keys()
session_key = get_session_key()
def _requires_api_key(path: str, demo: bool) -> bool:
"""Return ``True`` when *path* must present a G4F API key."""View on GitHub (pinned to 973504e177)
Solutions
- Check the username and password configured for the API server.
- Re-run authentication with valid credentials.
When it happens
Trigger: Thrown at g4f/api/__init__.py:547 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/6c2c77b157a8ea96.
Report an issue: GitHub.