{"id":25275327,"url":"https://github.com/xtekky/deepseek4free","last_synced_at":"2025-04-22T19:24:05.667Z","repository":{"id":274731958,"uuid":"923892859","full_name":"xtekky/deepseek4free","owner":"xtekky","description":"Deepseek V3 and R1 private API, deep thinking, search, full requests. pow challenge reversed. deepseek api.","archived":false,"fork":false,"pushed_at":"2025-02-07T10:53:54.000Z","size":32,"stargazers_count":73,"open_issues_count":4,"forks_count":20,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-07T11:35:15.261Z","etag":null,"topics":["deepseek","deepseek-api","deepseek-r1","deepseek-v3"],"latest_commit_sha":null,"homepage":"https://whop.com/reverser-academy/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xtekky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-29T02:33:32.000Z","updated_at":"2025-02-07T10:53:58.000Z","dependencies_parsed_at":"2025-01-29T03:35:31.315Z","dependency_job_id":null,"html_url":"https://github.com/xtekky/deepseek4free","commit_stats":null,"previous_names":["xtekky/deepseek4free"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtekky%2Fdeepseek4free","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtekky%2Fdeepseek4free/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtekky%2Fdeepseek4free/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtekky%2Fdeepseek4free/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xtekky","download_url":"https://codeload.github.com/xtekky/deepseek4free/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250307013,"owners_count":21409013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepseek","deepseek-api","deepseek-r1","deepseek-v3"],"created_at":"2025-02-12T15:01:29.416Z","updated_at":"2025-04-22T19:24:05.641Z","avatar_url":"https://github.com/xtekky.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# DeepSeek4Free\n\nA Python package for interacting with the DeepSeek AI chat API. This package provides a clean interface to interact with DeepSeek's chat model, with support for streaming responses, thinking process visibility, and web search capabilities.\n\n### Learn how to reverse engineer private api's !!\n- and reverse wasm like it was required here\n- [whop.com/reverser-academy](https://whop.com/reverser-academy/) (beta)\n\n\n\u003e ⚠️ **Service Notice**: DeepSeek API is currently experiencing high load. Work is in progress to integrate additional API providers. Please expect intermittent errors.\n\n\u003e 📝 **Note**: If you encounter any errors, please ensure you are using the latest version of this library. The DeepSeek API may change frequently, and updates are released to maintain compatibility.\n\n## ✨ Features\n\n- 🔄 **Streaming Responses**: Real-time interaction with token-by-token output\n- 🤔 **Thinking Process**: Optional visibility into the model's reasoning steps\n- 🔍 **Web Search**: Optional integration for up-to-date information\n- 💬 **Session Management**: Persistent chat sessions with conversation history\n- ⚡ **Efficient PoW**: WebAssembly-based proof of work implementation\n- 🛡️ **Error Handling**: Comprehensive error handling with specific exceptions\n- ⏱️ **No Timeouts**: Designed for long-running conversations without timeouts\n- 🧵 **Thread Support**: Parent message tracking for threaded conversations\n\n## 📦 Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/yourusername/deepseek4free.git\ncd deepseek4free\n```\n\n2. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n## 🔑 Authentication\n\nTo use this package, you need a DeepSeek auth token. Here's how to obtain it:\n\nIf you know how to use chrome devtools, simply run this snipped in the console:\n\n```js\nJSON.parse(localStorage.getItem(\"userToken\")).value\n```\n\n### Method 1: From LocalStorage (Recommended)\n\n\u003cimg width=\"1150\" alt=\"image\" src=\"https://github.com/user-attachments/assets/b4e11650-3d1b-4638-956a-c67889a9f37e\" /\u003e\n\n1. Visit [chat.deepseek.com](https://chat.deepseek.com)\n2. Log in to your account\n3. Open browser developer tools (F12 or right-click \u003e Inspect)\n4. Go to Application tab (if not visible, click \u003e\u003e to see more tabs)\n5. In the left sidebar, expand \"Local Storage\"\n6. Click on \"https://chat.deepseek.com\"\n7. Find the key named `userToken`\n8. Copy `\"value\"` - this is your authentication token\n\n### Method 2: From Network Tab\n\nAlternatively, you can get the token from network requests:\n\n1. Visit [chat.deepseek.com](https://chat.deepseek.com)\n2. Log in to your account\n3. Open browser developer tools (F12)\n4. Go to Network tab\n5. Make any request in the chat\n6. Find the request headers\n7. Copy the `authorization` token (without 'Bearer ' prefix)\n\n### Handling Cloudflare Challenges\n\nIf you encounter Cloudflare challenges (\"Just a moment...\" page), you'll need to get a `cf_clearance` cookie. Run this command:\n\n```bash\npython -m dsk.bypass\n```\n\nThis will:\n1. Open an undetected browser\n2. Visit DeepSeek and solve the Cloudflare challenge\n3. Capture and save the `cf_clearance` cookie\n4. The cookie will be automatically used in future requests\n\nYou only need to run this when:\n- You get Cloudflare challenges in your requests\n- Your existing cf_clearance cookie expires\n- You see the error \"Please wait a few minutes before trying again\"\n\nThe captured cookie will be stored in `dsk/cookies.json` and automatically used by the API.\n\n## 📚 Usage\n\n### Basic Example\n\n```python\nfrom dsk.api import DeepSeekAPI\n\n# Initialize with your auth token\napi = DeepSeekAPI(\"YOUR_AUTH_TOKEN\")\n\n# Create a new chat session\nchat_id = api.create_chat_session()\n\n# Simple chat completion\nprompt = \"What is Python?\"\nfor chunk in api.chat_completion(chat_id, prompt):\n    if chunk['type'] == 'text':\n        print(chunk['content'], end='', flush=True)\n```\n\n### Advanced Features\n\n#### Thinking Process Visibility\n\nThe thinking process shows the model's reasoning steps:\n\n```python\n# With thinking process enabled\nfor chunk in api.chat_completion(\n    chat_id,\n    \"Explain quantum computing\",\n    thinking_enabled=True\n):\n    if chunk['type'] == 'thinking':\n        print(f\"🤔 Thinking: {chunk['content']}\")\n    elif chunk['type'] == 'text':\n        print(chunk['content'], end='', flush=True)\n```\n\n#### Web Search Integration\n\nEnable web search for up-to-date information:\n\n```python\n# With web search enabled\nfor chunk in api.chat_completion(\n    chat_id,\n    \"What are the latest developments in AI?\",\n    thinking_enabled=True,\n    search_enabled=True\n):\n    if chunk['type'] == 'thinking':\n        print(f\"🔍 Searching: {chunk['content']}\")\n    elif chunk['type'] == 'text':\n        print(chunk['content'], end='', flush=True)\n```\n\n#### Threaded Conversations\n\nCreate threaded conversations by tracking parent messages:\n\n```python\n# Start a conversation\nchat_id = api.create_chat_session()\n\n# Send initial message\nparent_id = None\nfor chunk in api.chat_completion(chat_id, \"Tell me about neural networks\"):\n    if chunk['type'] == 'text':\n        print(chunk['content'], end='', flush=True)\n    elif 'message_id' in chunk:\n        parent_id = chunk['message_id']\n\n# Send follow-up question in the thread\nfor chunk in api.chat_completion(\n    chat_id,\n    \"How do they compare to other ML models?\",\n    parent_message_id=parent_id\n):\n    if chunk['type'] == 'text':\n        print(chunk['content'], end='', flush=True)\n```\n\n### Error Handling\n\nThe package provides specific exceptions for different error scenarios:\n\n```python\nfrom dsk.api import (\n    DeepSeekAPI, \n    AuthenticationError,\n    RateLimitError,\n    NetworkError,\n    CloudflareError,\n    APIError\n)\n\ntry:\n    api = DeepSeekAPI(\"YOUR_AUTH_TOKEN\")\n    chat_id = api.create_chat_session()\n    \n    for chunk in api.chat_completion(chat_id, \"Your prompt here\"):\n        if chunk['type'] == 'text':\n            print(chunk['content'], end='', flush=True)\n            \nexcept AuthenticationError:\n    print(\"Authentication failed. Please check your token.\")\nexcept RateLimitError:\n    print(\"Rate limit exceeded. Please wait before making more requests.\")\nexcept CloudflareError as e:\n    print(f\"Cloudflare protection encountered: {str(e)}\")\nexcept NetworkError:\n    print(\"Network error occurred. Check your internet connection.\")\nexcept APIError as e:\n    print(f\"API error occurred: {str(e)}\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtekky%2Fdeepseek4free","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxtekky%2Fdeepseek4free","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtekky%2Fdeepseek4free/lists"}