{"record":{"id":"08b4fcd188f2376e","repo":"xtekky/gpt4free","slug":"deepseekauth-no-authentication-found-please-add","errorCode":null,"errorMessage":"DeepSeekAuth: No authentication found. Please add a DeepSeek HAR file to har_and_cookies/ directory with an authorization token.","messagePattern":"DeepSeekAuth: No authentication found\\. Please add a DeepSeek HAR file to har_and_cookies/ directory with an authorization token\\.","errorType":"exception","errorClass":"MissingAuthError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/DeepSeek.py","lineNumber":399,"sourceCode":"            cookies: Optional cookies\n            proxy: Optional proxy\n            conversation: JsonConversation object for continuing sessions\n            web_search: Enable web search\n            media: List of (file_bytes, filename) tuples for file upload\n        \"\"\"\n        if not model:\n            model = cls.default_model\n\n        # Try to get auth from HAR file first\n        if cookies is None:\n            cookies = get_cookies(cls.cookie_domain, False)\n            headers = get_headers(cls.cookie_domain)\n            if cookies and headers.get(\"authorization\"):\n                debug.log(\n                    f\"DeepSeekAuth: Using {len(cookies)} cookies and {len(headers)} headers from cookie jar\"\n                )\n            else:\n                raise MissingAuthError(\n                    \"DeepSeekAuth: No authentication found. \"\n                    \"Please add a DeepSeek HAR file to har_and_cookies/ directory \"\n                    \"with an authorization token.\"\n                )\n\n        # Initialize conversation if needed\n        if conversation is None:\n            conversation = JsonConversation(parent_message_id=None)\n\n        # Get auth token from HAR data or conversation\n        authorization = None\n        if headers:\n            authorization = headers.get(\"authorization\")\n        elif hasattr(conversation, \"authorization\"):\n            authorization = conversation.authorization\n\n        if not authorization:\n            raise MissingAuthError(","sourceCodeStart":381,"sourceCodeEnd":417,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/DeepSeek.py#L381-L417","documentation":"MissingAuthError raised in DeepSeekAuth.create_async_generator when no cookies were passed explicitly and the fallback cookie jar lookup yields no (cookies + authorization header) pair. The message points at the remedy: import a DeepSeek HAR file containing an authorization token into har_and_cookies/.","triggerScenarios":"Invoking the DeepSeek provider without a cookies argument, with no HAR/cookie import present, or with an import whose headers lack \"authorization\". The nested condition requires both cookies and the auth header; missing either raises.","commonSituations":"First-time use of the authenticated DeepSeek provider; HAR file placed in the wrong directory; HAR captured before login so no bearer token; token-bearing request filtered out during export.","solutions":["Log in to chat.deepseek.com, record a HAR of a chat request, and save it under <g4f>/har_and_cookies/.","Verify the HAR contains the authorization request header (inspect any /chat_session or completion request in DevTools' Network tab).","Or pass cookies explicitly to create_async_generator if you manage sessions yourself.","Update g4f if DeepSeek changed endpoints and the importer no longer extracts the token."],"exampleFix":"# before\nresp = await client.chat.completions.create(model=..., provider=DeepSeek, messages=msgs)\n# MissingAuthError: ... add a DeepSeek HAR file ...\n\n# after\n# 1. browser DevTools -> Network -> send one chat on chat.deepseek.com\n# 2. save HAR to ./har_and_cookies/deepseek.har\nresp = await client.chat.completions.create(model=..., provider=DeepSeek, messages=msgs)","handlingStrategy":"validation","validationCode":"from g4f.requests import get_cookies, get_headers\nfrom g4f.Provider.needs_auth.DeepSeek import DeepSeek\n\ndef deepseek_provider_ready():\n    cookies = get_cookies(DeepSeek.cookie_domain, False)\n    headers = get_headers(DeepSeek.cookie_domain)\n    return bool(cookies and headers.get(\"authorization\"))\n\nif not deepseek_provider_ready():\n    raise SystemExit(\"Import a DeepSeek HAR with authorization into har_and_cookies/\")","typeGuard":null,"tryCatchPattern":"try:\n    resp = await client.chat.completions.create(model=m, provider=DeepSeek, messages=msgs)\nexcept MissingAuthError as e:\n    if \"HAR file\" in str(e):\n        guide_user_to_import_har()","preventionTips":["Automate HAR import as a setup step for the DeepSeek provider.","Validate cookie+authorization presence before dispatching requests.","Keep a runbook for re-capturing HARs when tokens expire."],"tags":["authentication","har-file","deepseek","cookies"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}