惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
博客园 - 【当耐特】
云风的 BLOG
云风的 BLOG
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
Engineering at Meta
Engineering at Meta
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
罗磊的独立博客
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
U
Unit 42
Microsoft Azure Blog
Microsoft Azure Blog
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
B
Blog RSS Feed
I
InfoQ
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
dsk++ — I rewrote a forgotten DeepSeek library to be full...
Fundiman · 2026-05-08 · via DEV Community

Fundiman

A while back, xtekky wrote a small library called deepseek4free for interacting with DeepSeek's chat infrastructure. It worked, but it was synchronous — meaning it blocked the event loop on every API call, making it painful to use in any async Python project.

I needed it for a Discord bot I was building, and the blocking behavior was causing real problems. So I rewrote it.

The result is dskpp (dsk++) — a drop-in async replacement that adds a few things the original never had.


What's new in dsk++

  • Fully async — built on curl_cffi async sessions, async for streaming, asyncio.to_thread() for WASM PoW
  • Concurrent file uploadsasyncio.gather() uploads multiple files simultaneously
  • Session deletionawait api.delete_chat_session(session_id)
  • Conversation historyawait api.get_history(session_id)
  • Proper error hierarchyAuthenticationError, RateLimitError, NetworkError, CloudflareError, UploadFilesUnavailable, APIError
  • Automatic Cloudflare detection and cookie refresh
  • Docker support via DOCKERMODE=true

The architecture

The library has three layers:

API layer (api.py) handles session management, streaming SSE parsing, file uploads, and automatic retry on Cloudflare blocks.

Bypass layer (server.py) is a FastAPI + Chromium automation server that solves Cloudflare challenges and extracts cookies.

PoW layer (pow.py) runs the WASM-based proof-of-work solver via asyncio.to_thread() so it doesn't block your event loop during CPU-bound hashing.


Quick example

import asyncio
from dskpp.api import DeepSeekAPI

async def main():
    api = DeepSeekAPI("your_token_here")

    session = await api.create_chat_session()

    # Upload files concurrently
    file_ids = await api.upload_files(["report.pdf", "data.xlsx"])

    # Stream response
    async for chunk in api.chat_completion(
        session,
        "Summarize these files",
        ref_file_ids=file_ids,
        search_enabled=False
    ):
        print(chunk.get("content", ""), end="")

    await api.delete_chat_session(session)
    await api.close()

asyncio.run(main())

Enter fullscreen mode Exit fullscreen mode

Before using the API, you need to generate cookies once:

python run_and_get_cookies.py

Enter fullscreen mode Exit fullscreen mode

This launches Chromium, solves the Cloudflare challenge, and stores cookies locally. After that, the client handles refresh automatically.


Getting your token

Log into chat.deepseek.com, open DevTools, go to Application → Local Storage → chat.deepseek.com → USER_TOKEN.


A word of caution

This is built on reverse-engineered infrastructure. DeepSeek can change their API at any time and break things. It may also violate their ToS — use at your own risk and don't do anything that would get your account banned.


Why bother?

The original library was solid but unmaintained and sync-only. For anyone building bots, automation tools, or anything async in Python, a blocking DeepSeek client is a dead end. This fixes that. Also not everyone can afford the DeepSeek API, so this helps people automate the web interface endpoints for chat.

Credit to xtekky and Doremii109 whose work this builds on.


GitHub → Fundiman/dskpp

Stars appreciated 🥺