xtekky/gpt4free · error · ProviderException
No user ID in auth response
Error message
No user ID in auth response
What it means
ProviderException raised when the GLM auth validation endpoint answered 2xx but the JSON payload does not contain a usable user object with an 'id' (neither data['user'] nor the top-level object has id). It guards against schema drift or unexpected payloads (HTML error pages parsed as empty JSON, API changes) so the provider never proceeds with an unidentifiable account.
Source
Thrown at g4f/Provider/glm/__init__.py:280
Returns dict with id, name, email, or raises ProviderException.
"""
async def _fetch():
async with session.get(
f"{GLM_BASE_URL}/api/v1/auths/",
headers={
"Authorization": f"Bearer {cls.api_key}",
"Content-Type": "application/json",
},
) as response:
if response.status >= 400:
raise ProviderException(
f"Cannot validate GLM account (status {response.status})"
)
data = await response.json()
user = data.get("user") or data
if not user or not user.get("id"):
raise ProviderException("No user ID in auth response")
return {
"id": str(user["id"]),
"name": user.get("name") or user.get("nickname") or "User",
"email": user.get("email", ""),
}
# Run in the async context — this is called from create_async_generator
import asyncio
return asyncio.get_event_loop().run_until_complete(_fetch())
@classmethod
async def _get_or_create_chat_session(cls, session, model: str) -> str:
"""Create a new chat session via /api/v1/chats/new (session.ts).
Returns the chat_id string.
"""
chat_id = str(uuid.uuid4())View on GitHub (pinned to 973504e177)
Solutions
- Update g4f to the latest version so the response parsing matches the current Z.ai API
- Manually curl GET {GLM_BASE_URL}/api/v1/auths/ with the Bearer key and inspect whether 'user.id' exists
- If using a proxy/mirror base URL, point GLM_BASE_URL at the official endpoint
Defensive patterns
Strategy: try-catch
Try / catch
try:
user = await GLM._validate_account(session)
except ProviderException as e:
if 'No user ID' in str(e):
log.error('Z.ai auth response schema changed — update g4f')
raise Prevention
- Pin and promptly update the g4f version when using web-session providers like GLM
- Add a canary request after key setup to catch schema drift early
- Avoid proxies that rewrite the auths/ response body
When it happens
Trigger: The /api/v1/auths/ response shape changed (user object renamed/nested differently), or the endpoint returned an empty/error JSON body with status 200 — e.g. behind a captive proxy or after a Z.ai API revision.
Common situations: Upstream Z.ai API schema changes not yet reflected in the installed g4f version; responses from a mirror/proxy that strips the user object.
Related errors
- PhindAi API returned success=False: {data}
- Failed to create chat: {data}
- Provider '{item}' not found
- Label must be provided
- Provider with label '{label}' not found
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/2bb66d92519b0e0d.
Report an issue: GitHub.