xtekky/gpt4free · error · ValueError

No appSession found in cookies for {cls.domain}, log in or p

Error message

No appSession found in cookies for {cls.domain}, log in or provide bearer_auth

What it means

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.

Source

Thrown at g4f/Provider/needs_auth/Reka.py:37

    @classmethod
    def create_completion(
        cls,
        model: str,
        messages: Messages,
        stream: bool = True,
        proxy: str = None,
        api_key: str = None,
        image: ImageType = None,
        **kwargs,
    ) -> CreateResult:
        cls.proxy = proxy

        if not api_key:
            cls.cookies = get_cookies(cls.domain, cache_result=False)
            if not cls.cookies:
                raise ValueError(f"No cookies found for {cls.domain}")
            elif "appSession" not in cls.cookies:
                raise ValueError(
                    f"No appSession found in cookies for {cls.domain}, log in or provide bearer_auth"
                )
            api_key = cls.get_access_token(cls)

        conversation = []
        for message in messages:
            conversation.append(
                {
                    "type": "human",
                    "text": message["content"],
                }
            )

        if image:
            image_url = cls.upload_image(cls, api_key, image)
            conversation[-1]["image_url"] = image_url
            conversation[-1]["media_type"] = "image"

View on GitHub (pinned to 973504e177)

Solutions

  1. Log in to Reka in the browser g4f reads cookies from, so appSession is set, then retry
  2. Pass api_key directly to bypass cookie auth entirely
  3. Clear the stale cookies for the domain and log in fresh

Example fix

# before
response = client.chat.completions.create(model='reka-core', messages=msgs)  # ValueError: no appSession

# after
response = client.chat.completions.create(model='reka-core', messages=msgs, api_key=os.environ['REKA_API_KEY'])
Defensive patterns

Strategy: validation

Validate before calling

from g4f.requests import get_cookies
c = get_cookies('reka.ai') or {}
if not os.environ.get('REKA_API_KEY') and 'appSession' not in c:
    raise SystemExit('Reka session missing: log in at reka.ai or set REKA_API_KEY')

Type guard

def has_reka_session(cookies: dict) -> bool:
    return 'appSession' in cookies and cookies['appSession']

Try / catch

try:
    result = ...create(...)
except ValueError as e:
    if 'appSession' in str(e):
        prompt_user_to_login('reka.ai')
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: Visited the site without signing in, session expired leaving stale non-auth cookies, partial cookie export missing the appSession entry.

Related errors


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