xtekky/gpt4free · error · RuntimeError
Failed to start conversation: {await resp.text()}
Error message
Failed to start conversation: {await resp.text()} What it means
CopilotApp POSTs to https://copilot.microsoft.com/c/api/start to create a conversation; any non-200 status raises with the response body attached. Common statuses: 401/403 (session not established), 429 (too many live sessions — the class tracks a 'live' counter), or 4xx from missing/invalid headers.
Source
Thrown at g4f/Provider/CopilotApp.py:67
}
start_payload = {
"timeZone": "Europe/Kiev",
"startNewConversation": True,
"teenSupportEnabled": True,
"correctPersonalizationSetting": True,
"deferredDataUseCapable": True,
}
try:
async with aiohttp.ClientSession() as session:
async with session.post(
"https://copilot.microsoft.com/c/api/start",
headers=headers,
json=start_payload,
proxy=proxy,
) as resp:
if resp.status != 200:
raise RuntimeError(
f"Failed to start conversation: {await resp.text()}"
)
start_data = await resp.json()
conversation_id = start_data.get("currentConversationId")
client_session_id = str(uuid.uuid4())
ws_url = f"wss://copilot.microsoft.com/c/api/chat?api-version=2&clientSessionId={client_session_id}"
async with session.ws_connect(ws_url, headers=headers, proxy=proxy) as ws:
async for msg in ws:
if msg.type == aiohttp.WSMsgType.TEXT:
data = json.loads(msg.data)
if data.get("event") == "connected":
break
model_lower = model.lower()
if (View on GitHub (pinned to 973504e177)
Solutions
- Read the status/body in the message: 401/403 → refresh auth cookies; 429 → back off and limit concurrency
- Ensure session-establishing cookies are included in the headers passed to create_async_generator
- Serialize or cap concurrent CopilotApp conversations to avoid session-limit rejections
Defensive patterns
Strategy: retry
Try / catch
try:
async for chunk in CopilotApp.create_async_generator(model, messages):
yield chunk
except RuntimeError as e:
text = str(e)
if '429' in text:
await asyncio.sleep(30) # session limit: back off
async for chunk in CopilotApp.create_async_generator(model, messages):
yield chunk
elif '401' in text or '403' in text:
raise AuthNeeded('CopilotApp session rejected — refresh cookies')
else:
raise Prevention
- Cap concurrent CopilotApp conversations (the provider tracks a live counter)
- Pass valid session cookies on every call; don't assume the provider establishes them
- Back off on 429; refresh auth on 401/403
When it happens
Trigger: Calling /c/api/start without valid session cookies; exceeding the provider's concurrent-session expectations (cls.live); request blocked by bot detection; malformed start_payload after an upstream schema change.
Common situations: Auth cookie not passed in headers; running many parallel CopilotApp requests from one IP; Microsoft requiring additional headers/turnstile token; proxy stripping cookies.
Related errors
- Error: {msg}
- WebSocket Error: {ws.exception()}
- Error during CopilotApp interaction: {e}
- Invalid response: {last_msg}
- Failed to upload file: {response.status} {error_text}
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/adec325b7643e16b.
Report an issue: GitHub.