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

推荐订阅源

博客园 - Franky
雷峰网
雷峰网
The Cloudflare Blog
WordPress大学
WordPress大学
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
IT之家
IT之家
V
V2EX
博客园 - 司徒正美
小众软件
小众软件
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Hugging Face - Blog
Hugging Face - Blog
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
博客园 - 叶小钗
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿

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 🥺