{"record":{"id":"108ec58964618c24","repo":"xtekky/gpt4free","slug":"no-appsession-found-in-cookies-for-cls-domain-l","errorCode":null,"errorMessage":"No appSession found in cookies for {cls.domain}, log in or provide bearer_auth","messagePattern":"No appSession found in cookies for (.+?), log in or provide bearer_auth","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/Reka.py","lineNumber":37,"sourceCode":"    @classmethod\n    def create_completion(\n        cls,\n        model: str,\n        messages: Messages,\n        stream: bool = True,\n        proxy: str = None,\n        api_key: str = None,\n        image: ImageType = None,\n        **kwargs,\n    ) -> CreateResult:\n        cls.proxy = proxy\n\n        if not api_key:\n            cls.cookies = get_cookies(cls.domain, cache_result=False)\n            if not cls.cookies:\n                raise ValueError(f\"No cookies found for {cls.domain}\")\n            elif \"appSession\" not in cls.cookies:\n                raise ValueError(\n                    f\"No appSession found in cookies for {cls.domain}, log in or provide bearer_auth\"\n                )\n            api_key = cls.get_access_token(cls)\n\n        conversation = []\n        for message in messages:\n            conversation.append(\n                {\n                    \"type\": \"human\",\n                    \"text\": message[\"content\"],\n                }\n            )\n\n        if image:\n            image_url = cls.upload_image(cls, api_key, image)\n            conversation[-1][\"image_url\"] = image_url\n            conversation[-1][\"media_type\"] = \"image\"\n","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/Reka.py#L19-L55","documentation":"Raised as ValueError by Reka when cookies for the domain exist but the required 'appSession' cookie is missing. The appSession cookie is the authenticated session marker Reka's /bff/auth/access_token endpoint needs; without it the cookie set is unusable for token exchange.","triggerScenarios":"Calling Reka without api_key when the browser has visited reka.ai but is not logged in (or the session cookie expired), so other cookies exist but appSession does not.","commonSituations":"Visited the site without signing in, session expired leaving stale non-auth cookies, partial cookie export missing the appSession entry.","solutions":["Log in to Reka in the browser g4f reads cookies from, so appSession is set, then retry","Pass api_key directly to bypass cookie auth entirely","Clear the stale cookies for the domain and log in fresh"],"exampleFix":"# before\nresponse = client.chat.completions.create(model='reka-core', messages=msgs)  # ValueError: no appSession\n\n# after\nresponse = client.chat.completions.create(model='reka-core', messages=msgs, api_key=os.environ['REKA_API_KEY'])","handlingStrategy":"validation","validationCode":"from g4f.requests import get_cookies\nc = get_cookies('reka.ai') or {}\nif not os.environ.get('REKA_API_KEY') and 'appSession' not in c:\n    raise SystemExit('Reka session missing: log in at reka.ai or set REKA_API_KEY')","typeGuard":"def has_reka_session(cookies: dict) -> bool:\n    return 'appSession' in cookies and cookies['appSession']","tryCatchPattern":"try:\n    result = ...create(...)\nexcept ValueError as e:\n    if 'appSession' in str(e):\n        prompt_user_to_login('reka.ai')\n    else:\n        raise","preventionTips":["Distinguish 'visited but not logged in' from 'never visited': always verify the appSession key specifically","Refresh sessions on a schedule; appSession expires independently of other cookies"],"tags":["authentication","cookies","session-expired","reka","g4f"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}