xtekky/gpt4free · error · ValueError

No cookies found for {cls.domain}

Error message

No cookies found for {cls.domain}

What it means

Raised as ValueError by the Reka provider when no api_key was passed and get_cookies(cls.domain) returned nothing — the browser cookie store has no cookies at all for Reka's domain. Without cookies the provider cannot mint an access token via its /bff/auth/access_token endpoint.

Source

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

    cookies = {}

    @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

View on GitHub (pinned to 973504e177)

Solutions

  1. Pass api_key (bearer token) directly to the call to skip cookie-based auth
  2. Log in to Reka in your default browser so g4f can read the cookies, then retry
  3. If cookies exist in a non-default browser profile, export them to where g4f's get_cookies looks

Example fix

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

# 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
if not os.environ.get('REKA_API_KEY') and not get_cookies('reka.ai'):
    raise SystemExit('Log in to reka.ai in your browser or set REKA_API_KEY')

Type guard

def reka_auth_ready(api_key: str | None) -> bool:
    if api_key:
        return True
    from g4f.requests import get_cookies
    return bool(get_cookies('reka.ai'))

Try / catch

try:
    result = ...create(model='reka-core', ...)
except ValueError as e:
    if 'No cookies found' in str(e):
        result = ...create(model='reka-core', api_key=os.environ['REKA_API_KEY'])
    else:
        raise

Prevention

When it happens

Trigger: Calling Reka without api_key on a machine whose browser has never logged in to the Reka domain, so the cookie lookup is empty.

Common situations: Fresh machine/container with no browser profile, cookies cleared, running headless in CI where no browser cookies exist.

Related errors


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