{"record":{"id":"6fdb20767727541d","repo":"xtekky/gpt4free","slug":"no-authentication-arguments-found","errorCode":null,"errorMessage":"No authentication arguments found.","messagePattern":"No authentication arguments found\\.","errorType":"exception","errorClass":"MissingAuthError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/LMArena.py","lineNumber":549,"sourceCode":"\n    @classmethod\n    def read_args(cls, args: dict = {}):\n        cache_file = cls.get_cache_file()\n        if not args and cache_file.exists():\n            try:\n                with cache_file.open(\"r\") as f:\n                    args = json.load(f)\n            except json.JSONDecodeError:\n                debug.log(f\"Cache file {cache_file} is corrupted, removing it.\")\n                cache_file.unlink()\n                args = None\n        return args\n\n    @classmethod\n    async def get_quota(cls, **kwargs):\n        args = cls.read_args()\n        if not args:\n            raise MissingAuthError(\"No authentication arguments found.\")\n        return {key: len(value) if value else 0 for key, value in args.items()}\n\n    @classmethod\n    async def create_async_generator(\n        cls,\n        model: str,\n        messages: Messages,\n        conversation: JsonConversation = None,\n        media: MediaListType = None,\n        proxy: str = None,\n        timeout: int = None,\n        **kwargs,\n    ) -> AsyncResult:\n        prompt = get_last_user_message(messages)\n        cache_file = cls.get_cache_file()\n        args = cls.read_args(kwargs.get(\"lmarena_args\", {}))\n        _need_clear_cookies = False\n        for _ in range(2):","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/LMArena.py#L531-L567","documentation":"LMArena.get_quota() reads persisted auth arguments (cookies/tokens) from the provider cache file via read_args(); when no args dict is available it raises MissingAuthError. It signals that the provider has never been authenticated, so quota counting (number of cookies per key) is impossible.","triggerScenarios":"Calling get_quota() before any successful create_async_generator() run, when the cache file does not exist, was corrupted and deleted (json.JSONDecodeError path unlinks it), or when neither lmarena_args nor kwargs supplied credentials.","commonSituations":"Fresh install with no prior browser login; a corrupted cache file was auto-removed; CI environments with a clean HOME so the .config/g4f cache path is empty.","solutions":["Run one authenticated request first (with nodriver installed) so LMArena writes the args cache file, then call get_quota()","Pass credentials directly via lmarena_args kwarg or place a valid args JSON at the cache file path (cls.get_cache_file())","Install the nodriver extra (pip install g4f[nodriver]) so the provider can harvest args from a headless browser session"],"exampleFix":"// before\nquota = await LMArena.get_quota()  # raises MissingAuthError\n\n// after\n# authenticate once (opens browser via nodriver) before asking for quota\nawait LMArena.create_async_generator(model='...', messages=[{'role':'user','content':'hi'}]).__anext__()\nquota = await LMArena.get_quota()","handlingStrategy":"validation","validationCode":"from g4f.Provider.needs_auth.LMArena import LMArena\nargs = LMArena.read_args()\nif not args:\n    # authenticate before asking for quota\n    await LMArena.create_async_generator(model=list(await LMArena.get_models_async())[0], messages=[{'role': 'user', 'content': 'ping'})).__anext__()\nquota = await LMArena.get_quota()","typeGuard":"def has_lmarena_args(args) -> bool:\n    return isinstance(args, dict) and len(args) > 0","tryCatchPattern":"from g4f.errors import MissingAuthError\ntry:\n    quota = await LMArena.get_quota()\nexcept MissingAuthError:\n    quota = None  # not authenticated yet; run one authed request first","preventionTips":["Seed the args cache with one authenticated request before monitoring quota","Keep the cache file path stable across deployments (same HOME)","Pass lmarena_args explicitly in stateless environments"],"tags":["lmarena","auth","cache","quota"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}