Unofficial Python client for DeepSeek — supports default & expert models, thinking, and web search.
Project description
p2d-deepseek
Unofficial Python client for DeepSeek. Supports default and expert models with thinking and web search — no special API needed, just your DeepSeek auth token.
Installation
Using pip (recommended):
pip install p2d-deepseek
Upgrade to latest version:
pip install p2d-deepseek --upgrade
Install specific version:
pip install p2d-deepseek==0.1.3
Note: The PyPI package is named
p2d-deepseekbut the Python import name isdeepseek. Install withpip install p2d-deepseek, then usefrom deepseek import DeepSeekClientin your code.
Getting Your Auth Token
To use this package, you need your DeepSeek auth token. Choose whichever method suits you best.
Method 1 — LocalStorage (Fastest, Desktop)
This is the quickest way if you are on a desktop browser.
- Go to chat.deepseek.com and log in
- Open DevTools — press
F12or right-click anywhere → Inspect - Go to the Application tab (if hidden, click
»to find it) - In the left sidebar, expand Local Storage → click
https://chat.deepseek.com - Find the key called
userToken - Copy the value field — that is your token
Method 2 — Network Tab (Desktop)
Use this if the LocalStorage method does not work for you.
- Go to chat.deepseek.com and log in
- Open DevTools → Network tab
- Send any message in the chat
- Click on any request going to
chat.deepseek.com - Open the Headers section
- Find the
authorizationheader and copy its value (without theBearerprefix)
Method 3 — Kiwi Browser (Android / Mobile)
Mobile users can extract the token using Kiwi Browser, which supports DevTools.
- Install Kiwi Browser from the Play Store
- Open chat.deepseek.com and log in
- Tap the menu (⋮) → Developer Tools
- Go to the Application tab → Local Storage →
https://chat.deepseek.com - Find the key called
userTokenand copy the value field
Note: Kiwi Browser is only available on Android. iPhone users can use a laptop or PC with any of the desktop methods above.
Cloudflare Issues
If you see a "Just a moment..." page or requests are being blocked, DeepSeek has triggered a Cloudflare challenge. In this case:
- Try logging out and back in on chat.deepseek.com
- Wait a few minutes, then grab a fresh token
- If the problem keeps happening, switch to a different network (e.g. mobile data vs Wi-Fi)
- Avoid making too many requests in a short time — space them out to stay under the radar
Your token is tied to your session. If DeepSeek logs you out or your session expires, just repeat any of the steps above to get a fresh one.
Quick Start
from deepseek import DeepSeekClient
client = DeepSeekClient(api_key="YOUR_TOKEN_HERE")
response = client.chat("What is the capital of France?")
print(response.response)
Models
| Model | Description |
|---|---|
default |
Standard DeepSeek model — fast, general purpose |
expert |
Expert model — deeper reasoning, more detailed answers |
Feature Flags
| Flag | Type | Default | Description |
|---|---|---|---|
model |
str |
"default" |
Model to use: "default" or "expert" |
thinking |
bool |
False |
Enable chain-of-thought reasoning |
search |
bool |
False |
Enable live web search |
session_id |
str |
None |
Reuse an existing chat session |
Usage Examples
Basic — default model
from deepseek import DeepSeekClient
client = DeepSeekClient(api_key="YOUR_TOKEN_HERE")
response = client.chat("Explain quantum computing")
print(response.response)
Expert model
response = client.chat(
"Solve this integral: ∫x²dx",
model="expert"
)
print(response.response)
Thinking enabled
response = client.chat(
"What is 17 * 23?",
thinking=True
)
print(response.response)
if response.thinking_content:
print("\n--- Thinking ---")
print(response.thinking_content)
Web search enabled
response = client.chat(
"What happened in the news today?",
search=True
)
print(response.response)
Expert + thinking
response = client.chat(
"Prove that sqrt(2) is irrational",
model="expert",
thinking=True
)
print(response.response)
Expert + web search
response = client.chat(
"Latest AI research papers in 2025",
model="expert",
search=True
)
print(response.response)
Default + thinking + web search
response = client.chat(
"What is today's weather in Mumbai?",
thinking=True,
search=True
)
print(response.response)
Expert + thinking + web search (all enabled)
response = client.chat(
"Analyze the current state of AI regulation globally",
model="expert",
thinking=True,
search=True
)
print(response.response)
if response.thinking_content:
print("\n--- Thinking Process ---")
print(response.thinking_content)
Continue a conversation (reuse session)
response1 = client.chat("My name is Alex")
session_id = response1.session_id
response2 = client.chat("What is my name?", session_id=session_id)
print(response2.response)
Response Object
Every client.chat() call returns a ChatResponse:
| Field | Type | Description |
|---|---|---|
response |
str |
The model's reply (clean plain text) |
thinking_content |
str | None |
Chain-of-thought (only when thinking=True) |
session_id |
str |
Session ID — use to continue conversations |
message_id |
int |
Message ID in the session |
model_type |
str |
Model used (default or expert) |
thinking_enabled |
bool |
Whether thinking was enabled |
search_enabled |
bool |
Whether web search was enabled |
status |
str |
Response status from DeepSeek |
Notes
- Tokens expire when your DeepSeek session ends — refresh using any method above
- Web search slightly increases response time but adds real-time data
- Thinking mode exposes the model's internal reasoning before the final answer
- All responses are automatically stripped of HTML tags and citation markers
License
MIT — made by addy
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file p2d_deepseek-0.1.4.tar.gz.
File metadata
- Download URL: p2d_deepseek-0.1.4.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed6c7ebc302cab362b85e4545fa662698d97d73beb3bfb5775f5c3b5d259b511
|
|
| MD5 |
2085c7e4397617492694cfb844a91b79
|
|
| BLAKE2b-256 |
6e69aebbcf189588d1c4cdd4d0865ca481a0e7173de97b63d86c204a957b76bc
|
File details
Details for the file p2d_deepseek-0.1.4-py3-none-any.whl.
File metadata
- Download URL: p2d_deepseek-0.1.4-py3-none-any.whl
- Upload date:
- Size: 23.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56450dc703dd6560ec8f1fce080c76d424a48c29c17724228bf7433ac683e720
|
|
| MD5 |
163880606af4de405f3a00edcf3e56a8
|
|
| BLAKE2b-256 |
17517f9570d6038556355eb2fbbe398340b42f8ee38cedccc588eef3a527d48e
|