xtekky/gpt4free · error · NoValidHarFileError

No proof_token found in .har files

Error message

No proof_token found in .har files

What it means

Raised at the end of get_request_config(): after readHAR() processed every available .har file, request_config.proof_token is still None. The proof token is extracted from the 'proof_token' entries in the HAR (the OpenAI anti-bot persona/config payload); if no captured request contained it, the flow cannot authenticate and NoValidHarFileError is raised.

Source

Thrown at g4f/Provider/openai/har_file.py:202

def getBw(bt: int) -> str:
    return str(bt - (bt % 21600))


def getN() -> str:
    timestamp = str(int(time.time()))
    return base64.b64encode(timestamp.encode()).decode()


async def get_request_config(
    request_config: RequestConfig, proxy: str
) -> RequestConfig:
    readHAR(request_config)
    if request_config.arkose_request is not None:
        request_config.arkose_token = await sendRequest(
            genArkReq(request_config.arkose_request), proxy
        )
    if request_config.proof_token is None:
        raise NoValidHarFileError("No proof_token found in .har files")
    return request_config

View on GitHub (pinned to 973504e177)

Solutions

  1. Re-capture a fresh HAR: log into chatgpt.com, DevTools > Network on, send one real message, export
  2. Update g4f — proof token extraction is adapted when OpenAI changes the payload
  3. Keep multiple recent .har files; readHAR scans all of them sorted by mtime
  4. If HAR auth keeps failing, switch the OpenAI provider to an api_key-based configuration
Defensive patterns

Strategy: validation

Validate before calling

import json

def har_has_proof_token(path: str) -> bool:
    with open(path, 'rb') as f:
        try:
            raw = f.read()
        except OSError:
            return False
    return b'proof_token' in raw or b'proofToken' in raw

Try / catch

from g4f.errors import NoValidHarFileError
try:
    cfg = await get_request_config(request_config, proxy)
except NoValidHarFileError as e:
    if 'proof_token' in str(e):
        recapture_har_after_chat_message()
        raise

Prevention

When it happens

Trigger: All .har files were read but none contained a request/response carrying the proof token (e.g. capture missed the conversation request, or the token lives under a request shape readHAR no longer matches).

Common situations: HAR captured on a page load without a chat submission; OpenAI changing the field name/location of the proof token; stale HAR from before an OpenAI frontend update; JSON-valid but truncated HAR exports.

Related errors


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