{"record":{"id":"79a6dc655737103d","repo":"xtekky/gpt4free","slug":"install-curl-cffi-package-pip-install-u-curl","errorCode":null,"errorMessage":"Install \"curl_cffi\" package | pip install -U curl_cffi","messagePattern":"Install \"curl_cffi\" package \\| pip install -U curl_cffi","errorType":"exception","errorClass":"MissingRequirementsError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/hf/HuggingChat.py","lineNumber":110,"sourceCode":"            yield AuthResult(\n                cookies=cookies, headers=DEFAULT_HEADERS, impersonate=\"chrome\"\n            )\n\n    @classmethod\n    async def create_authed(\n        cls,\n        model: str,\n        messages: Messages,\n        auth_result: AuthResult,\n        prompt: str = None,\n        media: MediaListType = None,\n        return_conversation: bool = True,\n        conversation: Conversation = None,\n        web_search: bool = False,\n        **kwargs,\n    ) -> AsyncResult:\n        if not has_curl_cffi:\n            raise MissingRequirementsError(\n                'Install \"curl_cffi\" package | pip install -U curl_cffi'\n            )\n        model = cls.get_model(model)\n\n        session = Session(**auth_result.get_dict())\n\n        if conversation is None or not hasattr(conversation, \"models\"):\n            conversation = Conversation({})\n\n        if model not in conversation.models:\n            conversationId = cls.create_conversation(session, model)\n            debug.log(f\"Conversation created: {json.dumps(conversationId[8:] + '...')}\")\n            messageId = cls.fetch_message_id(session, conversationId)\n            conversation.models[model] = {\n                \"conversationId\": conversationId,\n                \"messageId\": messageId,\n            }\n            inputs = format_prompt(messages)","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/hf/HuggingChat.py#L92-L128","documentation":"Raised by HuggingChat.create_async_generator when the optional curl_cffi package is not installed. HuggingChat's Session wrapper depends on curl_cffi to present a browser-like TLS fingerprint to huggingface.co; without it the provider refuses to run rather than failing mid-request. It is a MissingRequirementsError, so it is purely an environment problem.","triggerScenarios":"Instantiating/calling the HuggingChat provider (hf chat models) in an environment where `import curl_cffi` failed and has_curl_cffi is False.","commonSituations":"Minimal installs of g4f that skipped provider extras; Docker images trimmed for size; CI environments where only core requirements were pinned.","solutions":["Run: pip install -U curl_cffi","Verify with: python -c \"import curl_cffi\"","If you don't need HuggingChat, route requests to a provider without the curl_cffi dependency"],"exampleFix":"# before\n# MissingRequirementsError: Install \"curl_cffi\" package\n# after\npip install -U curl_cffi\npython -c \"from curl_cffi import requests; print('ok')\"","handlingStrategy":"validation","validationCode":"def huggingchat_ready() -> bool:\n    try:\n        import curl_cffi  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\nif not huggingchat_ready():\n    raise SystemExit(\"pip install -U curl_cffi\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add curl_cffi to requirements whenever HuggingChat is in your provider set","Run an import check at startup before selecting providers","Include provider extras in Docker builds: pip install g4f[all]"],"tags":["huggingchat","dependencies","environment","missing-requirements"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}