xtekky/gpt4free · error · MissingRequirementsError

cloudscraper library is required for Yupp provider | install

Error message

cloudscraper library is required for Yupp provider | install it via 'pip install cloudscraper'

What it means

Raised as MissingRequirementsError at the top of Yupp.create_async_generator() when the optional cloudscraper package is absent. Yupp sits behind Cloudflare protection and uses cloudscraper-based sessions (create_scraper()) for every request, so the dependency is mandatory for chat generation even though the provider module itself imports lazily.

Source

Thrown at g4f/Provider/Yupp.py:573

            load_yupp_accounts(api_key)
        else:
            raise MissingAuthError(
                "No Yupp accounts configured. Set YUPP_API_KEY environment variable."
            )
        credits = await get_credits(create_scraper(), await get_best_yupp_account())
        return {"credits": {"remaining": credits, "total": 5000}}

    @classmethod
    async def create_async_generator(
        cls,
        model: str,
        messages: Messages,
        proxy: str = None,
        api_key: str = None,
        **kwargs,
    ) -> AsyncResult:
        if not has_cloudscraper:
            raise MissingRequirementsError(
                "cloudscraper library is required for Yupp provider | install it via 'pip install cloudscraper'"
            )
        if not api_key:
            api_key = AuthManager.load_api_key(cls)
        if not api_key:
            api_key = get_cookie_tokens()
        if api_key:
            load_yupp_accounts(api_key)
            log_debug(f"Yupp provider initialized with {len(YUPP_ACCOUNTS)} accounts")
        else:
            raise MissingAuthError(
                "No Yupp accounts configured. Set YUPP_API_KEY environment variable."
            )

        conversation = kwargs.get("conversation")
        url_uuid = conversation.url_uuid if conversation else None
        is_new_conversation = url_uuid is None

View on GitHub (pinned to 973504e177)

Solutions

  1. pip install cloudscraper
  2. Install the g4f extras that bundle scraping dependencies (e.g. pip install g4f[all])
  3. Add cloudscraper to requirements.txt / pyproject dependencies for deployments that use Yupp
  4. Pin a recent cloudscraper version so Cloudflare bypass rules are current

Example fix

# before
# cloudscraper missing -> MissingRequirementsError
response = await client.chat.completions.create(model='...', provider='Yupp', ...)

# after (shell)
# pip install cloudscraper
Defensive patterns

Strategy: validation

Validate before calling

from g4f.Provider.Yupp import has_cloudscraper

def yupp_usable():
    return has_cloudscraper and bool(os.getenv('YUPP_API_KEY') or get_cookie_tokens())

Try / catch

try:
    ...  # chat call routed to Yupp
except MissingRequirementsError as e:
    if 'cloudscraper' in str(e):
        subprocess.run([sys.executable, '-m', 'pip', 'install', 'cloudscraper'])  # or disable provider

Prevention

When it happens

Trigger: Calling create_async_generator (any chat completion routed to Yupp) in an environment where 'import cloudscraper' failed at module load, i.e. has_cloudscraper is False.

Common situations: Installing g4f without the [all] / web extras; slim Docker images; dependency stripped by a lockfile or pruned virtualenv.

Related errors


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