Skip to main content

A free, unofficial client for the DeepSeek API with a Google Gemini-like syntax.

Project description

OpenDeep 🚀

OpenDeep is an elegant, free, and unofficial Python client for the DeepSeek API. It provides a clean, Google Gemini-like syntax while seamlessly handling DeepSeek's underlying security mechanisms (Cloudflare bypass, Proof of Work challenges, and Server-Sent Events).

Whether you need quick text generation or complex reasoning from the DeepSeek V4 Pro model, OpenDeep abstracts away the messy backend logic so you can focus on building.

✨ Key Features

  • 💎 Gemini-Like Syntax: Familiar and highly readable API design (model.generate_content).
  • 🛡️ Cloudflare Bypass: Uses curl_cffi to impersonate browser TLS fingerprints, preventing blocking.
  • 🧩 Native POW Solver: WebAssembly-powered challenge solver to effortlessly bypass DeepSeek's rate-limiting/bot protection.
  • 📡 Real-Time Streaming: Full support for Server-Sent Events (SSE) parsing, including the newest DeepSeek patch formats.
  • 🧠 Thinking Support (DeepSeek V4 Pro): Seamlessly handles the "thinking" process of the advanced reasoning models.

📦 Installation

Ensure you have Python 3.8+ installed. You can install the required dependencies using pip:

pip install -r requirements.txt

🚀 Quick Start

1. Get your API Key (User Token)

To use OpenDeep, you need your active session token from the browser:

  1. Log into chat.deepseek.com.
  2. Open your browser's Developer Tools (F12) -> Application (or Storage) -> Local Storage.
  3. Find the key named userToken and copy its value.

2. Basic Usage (Without Streaming)

If you just want the final answer without any real-time console output or "thinking" logs, set stream=False (this is the default behavior).

import opendeep as genai

genai.configure(api_key="your_userToken_here")
model = genai.GenerativeModel("deepseek-v4-flash") # V4 Flash model

# Waits for the full generation to complete
response = model.generate_content("Explain the theory of relativity in simple terms.")

print("Final Output:")
print(response.text)

3. Real-Time Streaming & Reasoner Output

When using the deepseek-v4-pro model with stream=True, OpenDeep will stream the internal "thinking" process directly to your console in a subtle gray color, followed by the actual answer.

import opendeep as genai

genai.configure(api_key="your_userToken_here")

# Select the reasoning model (V4 Pro)
model = genai.GenerativeModel("deepseek-v4-pro")

# stream=True enables real-time console output
# It will print the reasoning process (in gray) and then the final answer!
response = model.generate_content("How many R's are in the word strawberry?", stream=True)

# The response object still captures the final text (excluding the thinking process)
print(f"\nCaptured text length: {len(response.text)} characters")

💡 Note on Reasoner and Streams:

  • If you use deepseek-v4-pro with stream=True, you will see the thoughts live in the console.
  • If you use deepseek-v4-pro with stream=False, the thoughts are silently discarded during processing, and you only get the final, clean answer in response.text.

🏗️ Architecture Under the Hood

  • models.py: Handles the HTTP session, impersonation, header generation, stream decoding, and payload construction.
  • pow.py: A highly optimized WebAssembly (WASM) bridge that calculates Custom SHA3 hashes for DeepSeek's Proof of Work challenge.
  • config.py: Global state management for authentication and endpoints.

🛠️ Troubleshooting

  • 422 Unprocessable Entity: This usually means your userToken is invalid or expired. Get a fresh one from your browser.
  • Cloudflare / Empty Response: Ensure curl_cffi is properly installed. Standard requests will get blocked by Cloudflare.
  • WASM errors: Make sure both wasmtime and numpy are installed to solve the Proof of Work challenges.

📜 Disclaimer

This is an unofficial, reverse-engineered client intended for educational purposes and personal use. DeepSeek may update their internal APIs or protection mechanisms at any time. Use responsibly!


made with hate to corps by @cmpdchtr

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opendeep-0.2.0.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opendeep-0.2.0-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

Details for the file opendeep-0.2.0.tar.gz.

File metadata

  • Download URL: opendeep-0.2.0.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for opendeep-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8b0d3a0876879638ba8c0cafab03f89da41ccf7f906db2aea5ae6fc1375c9bd6
MD5 9ae70c14947e9f9c773c51406c7c1a78
BLAKE2b-256 f29cc4edc800519722fd9118df4c8764113080ff0471211a6f911b83358901ab

See more details on using hashes here.

File details

Details for the file opendeep-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: opendeep-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 22.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for opendeep-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 445fa5844e909734ccb8e653b4ee8d8a8ee59bfa24d66159086de3e06bcafa12
MD5 8667d4989abd4f960fb91582cce451ec
BLAKE2b-256 ed0116414de3b92a869dbc9df912e8b1256142ecc408a646aebfe7a4ff9e856d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page