Python client library for unofficial DeepSeek Web API with automatic PoW challenge solving, automatic model mapping, and built-in auto-healing retries.
pip install deepseek-api
# or with uv
uv add deepseek-apifrom deepseek_api import DeepSeek, login
# Initialize client with authorization token
client = DeepSeek(auth_token="Bearer eyJhbGciOi...")
# Create a conversation session
session = client.new_session()
# Send a chat message (supports automatic model mapping for 'deepseek-v3', 'deepseek-r1')
response = session.send_message("Hello, how are you?", model="deepseek-v3")
print("Response:", response["content"]["response"])
# Stream a response in real-time
for event_type, chunk in session.send_message_stream("Explain quantum physics simply", model="deepseek-r1"):
if event_type in ("content", "thought"):
print(chunk, end="", flush=True)- Single Authorization Token: Only requires
auth_token(no Cookie header needed). - Auto Model Mapping: Automatically resolves parameters (
thinking_enabled,model_type) for models such asdeepseek-v3anddeepseek-r1. - Built-in Auto-Healing Retries: Retries up to 3 times automatically on transient 40300 errors, network timeouts, or expired chat rooms.
- WASM PoW Solver: Solves DeepSeek proof-of-work challenges natively using
curl_cffiand WASM execution. - Stateful Conversation: Manages
chat_session_idandparent_message_idacross turns.
MIT