Fly143/deepseek-free-api
Fly143/deepseek-free-api has 343 GitHub stars and 84 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-17 04:52 UTC. Last push 2026-11-09.
Measured star growth
- in 24h
- 0
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
About
将 DeepSeek 网页端免费对话(chat.deepseek.com)转换为 OpenAI + Anthropic 兼容 API(Chat Completions / Responses / Anthropic Messages)支持工具调用(Function Calling)、动态模型发现、PoW 自动求解、Token 自动刷新。
Developer ToolsREADME_EN.md
OriginalDeepSeek Free API Proxy
🚨🚨🚨 Ban Warning 🚨🚨🚨
⛔ Severe account-ban issues — this project is NOT recommended for use ⛔
DeepSeek's official detection keeps tightening. Penalties escalate with each offense:
🔴 1st offense → 1-day ban | 2nd → 3-day ban | 3rd → 8-day ban → PERMANENT ban
Reverse-engineer DeepSeek web chat (chat.deepseek.com) into an OpenAI-compatible API, with dynamic model discovery, automatic PoW solving, and token refresh.
Reverse-engineer DeepSeek web chat (chat.deepseek.com) into an OpenAI-compatible API, with dynamic model discovery, automatic PoW solving, and token refresh.
本项目所修改代码均为ai完成,不含任何一句人工代码,望周知!
📖 中文版本
zhangjiabo522 — Thanks for providing model tokens for Vision feature testing!
⚠️ The
no-toolsbranch is discontinued — no longer receives feature updates or bug fixes.
Reference project: NIyueeE/ds-free-api (Rust). This is a Python rewrite using pure HTTP forwarding (curl_cffi with Chrome TLS fingerprint) instead of browser automation, with lower resource usage.
Table of Contents
- Features
- Architecture
- Quick Start
- Authentication
- API Usage
- Anthropic Messages API
- Model System
- Tool Calling
- Branch Info
- PoW Solver
- Sessions and credentials
- Management Commands
- Project Structure
- Configuration Reference
- Dependencies
- Limitations & Known Issues
- FAQ
- License & Credits
Features
- OpenAI Fully Compatible —
/v1/chat/completions(streaming/non-streaming),/v1/models,/v1/models/refresh,/v1/responsesendpoints - OpenAI Responses API —
/v1/responsescreate/retrieve/delete/input_items/cancel/compact, full SSE lifecycle events, Structured Output support - Pure Chat Proxy — No tool call prompt injection, cleaner output, model attention focused on user queries
- Dynamic Model Discovery — Real-time model list fetched from DeepSeek official API at startup, auto-refreshes hourly (includes context size and full metadata)
- Automatic PoW Solving — Node.js WASM primary solver + Python pure algorithm fallback, auto-fetches and solves challenges before each request
- Account credentials — Re-login through the admin panel when credentials expire
- Deep Thinking — Supports DeepSeek's
<thought>tags, separated asreasoning_contentin streaming output - Vision — Image upload, parsing, and conversation
- Text File Upload — Upload .txt/.md/.py files for chat via
ref_file_ids(same as web UI) - Web Search —
search_enabledparameter for search model variants - Multilingual Admin Panel — Embedded single-file Web UI, Chinese/English toggle, phone/email login, cURL import
- Pure HTTP Solution — No browser/Playwright/Chrome dependency, uses curl_cffi to emulate Chrome TLS fingerprint
- No-Tools Branch (discontinued) — The
no-toolsbranch is no longer maintained and does not receive feature updates or bug fixes
Architecture
┌──────────────────────────────────────────────────────────┐
│ OpenAI Compatible Client │
│ (ChatBox / LobeChat / curl / Cline) │
└───────────────┬──────────────────────────────────────────┘
│ /v1/chat/completions
▼
┌──────────────────────────────────────────────────────────┐
│ DeepSeek Free API Proxy (FastAPI) │
│ ┌─────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ Routes │ │ tool_call │ │ tool_sieve │ tool_dsml │ │
│ │ /v1/* │──│ (tool prompt)│──│ (streaming │ (DSML │ │
│ └─────────┘ │ injection) │ │ sieve) │ parser) │ │
│ └──────────────┘ └──────────────────────┘ │
│ ┌─────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ Model │ │ PoW Solver │ │ Token Refresh │ │
│ │ Disc. │ │ (Node+Python)│ │ (admin re-login) │ │
│ └─────────┘ └──────────────┘ └──────────────────────┘ │
│ ┌─────────┐ ┌──────────────┐ │
│ │ curl │ │ Vision/Files │ │
│ │ (Chrome │ │ (upload→fork │ │
│ │ TLS) │ │ →wait) │ │
│ └─────────┘ └──────────────┘ │
└───────────────┬──────────────────────────────────────────┘
│ HTTPS (curl_cffi, Chrome fingerprint)
▼
┌──────────────────────────────────────────────────────────┐
│ DeepSeek API (chat.deepseek.com) │
│ /api/v0/chat/completion (SSE) │
│ /api/v0/users/login │
│ /api/v0/chat_session/create │
│ /api/v0/chat/create_pow_challenge │
│ /api/v0/client/settings │
│ /api/v0/file/upload_file + fork_file_task │
└──────────────────────────────────────────────────────────┘
Quick Start
One-Click Deploy (Recommended)
# Install Node.js first (required by PoW solver)
# Termux:
pkg install nodejs
# Linux:
# sudo apt install nodejs
# Clone the repo
git clone https://github.com/Fly143/deepseek-free-api.git
cd deepseek-free-api
chmod +x deploy.sh
# Foreground (Ctrl+C to stop)
./deploy.sh
# Or background
./deploy.sh --bg
# Check status
./deploy.sh --status
# Stop
./deploy.sh --stop
After deployment, visit: http://localhost:8000/admin (default credentials: admin / admin, changeable in admin panel settings)
Docker
docker run -d -p 8000:8000 -v deepseek-data:/data ghcr.io/fly143/deepseek-free-api:latest sh -c 'ln -sf /data/config.json /app/config.json && ln -sf /data/.secret_key /app/.secret_key && exec python proxy.py'
⚠️
no-toolsbranch discontinued.
Manual Install
# 1. Ensure Python 3.10+ and Node.js
python3 --version
node --version
# 2. Install Python dependencies
pip install fastapi uvicorn curl-cffi python-dotenv tiktoken cryptography jsonschema
# 3. Start
python3 proxy.py
Authentication
Open the admin panel at http://localhost:8000/admin to configure.
Method 1: Phone/Email Login (Recommended)
The easiest way, same experience as the web login:
- Select the Phone or Email tab
- Enter your phone number (area code defaults to +86) or email
- Enter your password
- Click Login
The system automatically completes: login to get Token → create chat Session → save account configuration to config.json.
Method 2: cURL Import
- Log in to chat.deepseek.com
- Open DevTools → Network panel
- Send a message, find the
completionrequest - Right-click → Copy as cURL
- In the admin panel, expand Advanced: Paste cURL and paste it
- Click Save cURL
Method 3: Cookie Import
- Log in to chat.deepseek.com
- Open DevTools → Application → Cookies
- Find cookies for
chat.deepseek.com - Export the cookie string containing
userToken - Paste into the admin panel → Save
API Usage
1. List Models
curl http://localhost:8000/v1/models
Returns all dynamically discovered models with max_input_tokens, max_output_tokens, and other details.
2. Non-streaming Chat
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-default",
"messages": [
{"role": "user", "content": "Write a quicksort in Python"}
]
}'
3. Streaming Chat
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-reasoner",
"messages": [
{"role": "user", "content": "Explain quantum entanglement"}
],
"stream": true
}'
In streaming responses, thinking content appears in delta.reasoning_content, while actual content is in delta.content.
4. File Upload (Text & Images)
Text file upload (supported by all models, no fork, via ref_file_ids):
# Prepare file base64
FILE_B64=$(base64 -w0 notes.txt)
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-default",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is this file about?"},
{"type": "file", "file": {"filename": "notes.txt", "file_data": "'"$FILE_B64"'"}}
]
}]
}'
Vision image upload (requires Vision model, fork to vision type after upload):
# Prepare image base64
IMG_B64=$(base64 -w0 photo.png)
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-vision",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Describe this image"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,'"$IMG_B64"'"}}
]
}]
}'
Note: Text files do not fork — wait for DeepSeek to finish parsing and reference the original
file_id. Images must fork to"vision"to be readable by Vision models.
5. Responses API (OpenAI Compatible)
Supports OpenAI's latest /v1/responses endpoint. Non-streaming:
curl http://localhost:8000/v1/responses \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek",
"input": "Write a quicksort in Python",
"stream": false
}'
Streaming (with full SSE lifecycle events):
curl http://localhost:8000/v1/responses \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek",
"input": "Explain quantum entanglement",
"stream": true
}'
Events: response.created → response.in_progress → response.output_item.added → response.content_part.added → response.output_text.delta(chunks) → response.output_text.done → response.content_part.done → response.output_item.done → response.completed
Other endpoints (supports streaming replay):
# Retrieve
curl http://localhost:8000/v1/responses/{response_id}
# Input items
curl http://localhost:8000/v1/responses/{response_id}/input_items
# Cancel
curl -X POST http://localhost:8000/v1/responses/{response_id}/cancel
# Delete
curl -X DELETE http://localhost:8000/v1/responses/{response_id}
# Compact multi-turn conversations
curl -X POST http://localhost:8000/v1/responses/{response_id}/compact \
-H "Content-Type: application/json" \
-d '{"instructions": "Please answer all subsequent questions in Chinese"}'
Structured Output (json_schema):
curl http://localhost:8000/v1/responses \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek",
"input": "Beijing weather today 25°C, return structured data",
"text": {
"format": {
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"city": {"type": "string"},
"temperature": {"type": "integer"},
"unit": {"type": "string"}
},
"required": ["city", "temperature", "unit"]
}
}
}
}'
The Responses API supplements the existing
/v1/chat/completions— both can be used simultaneously.
6. Anthropic Messages API
This proxy is fully compatible with the Anthropic Messages API format, supporting seamless integration for clients like RikkaHub.
Authentication: Use either x-api-key header or Authorization: Bearer:
# x-api-key method (recommended)
curl http://localhost:8000/v1/messages \
-H "x-api-key: sk-dsapi" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-default",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Write a quicksort in Python"}
]
}'
Streaming (thinking + text):
curl http://localhost:8000/v1/messages \
-H "x-api-key: sk-dsapi" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-reasoner",
"max_tokens": 1024,
"stream": true,
"messages": [
{"role": "user", "content": "Explain quantum entanglement"}
]
}'
Thinking content streams as thinking blocks, text as text blocks.
Available Endpoints:
| Method | Endpoint | Description |
|---|---|---|
| POST | /v1/messages |
Send message (text / thinking) |
| POST | /v1/messages/count_tokens |
Count tokens |
| GET | /v1/messages/{id} |
Retrieve sent message |
| POST | /v1/messages/batches |
Create batch request |
| GET | /v1/messages/batches |
List batches |
| GET | /v1/messages/batches/{id} |
Get batch details |
| POST | .../cancel |
Cancel batch |
| GET | .../results |
Download batch results |
| DELETE | /v1/messages/batches/{id} |
Delete batch |
Anthropic Model Name Aliases
Tools like Claude Code CLI expect Anthropic-style model names (e.g., claude-sonnet-4-6) and cannot directly use deepseek-* native names. This proxy automatically maps them internally on Anthropic endpoints:
| Claude Model | → DeepSeek Internal | Thinking | Search |
|---|---|---|---|
claude-opus-4-6 |
deepseek-expert-reasoner |
✓ | ✗ |
claude-opus-4-6-search |
deepseek-expert-reasoner-search |
✓ | ✓ |
claude-sonnet-4-6 |
deepseek-reasoner |
✓ | ✗ |
claude-sonnet-4-6-search |
deepseek-reasoner-search |
✓ | ✓ |
claude-haiku-4-5 |
deepseek-default |
✗ | ✗ |
claude-sonnet-4-6-nothinking |
deepseek-default |
✗ | ✗ |
claude-3-7-sonnet |
deepseek-reasoner |
✓ | ✗ |
claude-3-5-sonnet |
deepseek-default |
✗ | ✗ |
claude-3-opus |
deepseek-expert-reasoner |
✓ | ✗ |
Also supports Claude 4.x legacy names (claude-sonnet-4-5, claude-opus-4-1, etc.) and -nothinking variants. DeepSeek native names (deepseek-*) continue to work directly; /v1/models still returns native names, not affecting other software.
# Claude model names work too
curl http://localhost:8000/v1/messages \
-H "x-api-key: sk-dsapi" \
-d '{"model":"claude-sonnet-4-6","max_tokens":100,"messages":[{"role":"user","content":"hi"}]}'
7. Model Refresh
# Force refresh model list (no need to wait 1-hour cache expiry)
curl -X POST http://localhost:8000/v1/models/refresh
Model System
Dynamic Model Discovery
At startup, the proxy automatically calls DeepSeek's official API GET /api/v0/client/settings (params: did, scope=model) to obtain currently available model configurations.
Core discovery logic (proxy.py:418):
def _discover_models():
resp = cffi_requests.get(
"https://chat.deepseek.com/api/v0/client/settings",
params={"did": str(uuid.uuid4()), "scope": "model"},
headers={"Authorization": f"Bearer {token}", ...}
)
# Parse model_configs, generate base/think/search/think+search variants by model_type
- Auto-detect: No need to manually update model lists
- 1-hour cache: Avoids frequent requests
- Manual refresh:
POST /v1/models/refresh - Fault-tolerant: Detection failure does not affect cached lists
Each model returns:
max_input_tokens— maximum input tokensmax_output_tokens— maximum output tokens (including thinking)thinking_enabled— whether deep thinking is supportedsearch_enabled— whether web search is supported
Currently Available Models
The model list changes dynamically with DeepSeek. Currently 3 base models × 4 variants = 12 models detected:
| Model ID | Name | Description | Thinking | Search |
|---|---|---|---|---|
deepseek-default |
DeepSeek V4 Flash | V4 Flash fast base model | ✗ | ✗ |
deepseek-reasoner |
DeepSeek V4 Flash Thinking | V4 Flash + deep thinking | ✓ | ✗ |
deepseek-search |
DeepSeek V4 Flash Search | V4 Flash + web search | ✗ | ✓ |
deepseek-reasoner-search |
DeepSeek V4 Flash Think+Search | V4 Flash + think + search | ✓ | ✓ |
deepseek-expert |
DeepSeek V4 Pro | V4 Pro expert base model | ✗ | ✗ |
deepseek-expert-reasoner |
DeepSeek V4 Pro Thinking | V4 Pro + deep thinking | ✓ | ✗ |
deepseek-expert-search |
DeepSeek V4 Pro Search | V4 Pro + web search | ✗ | ✓ |
deepseek-expert-reasoner-search |
DeepSeek V4 Pro Think+Search | V4 Pro + think + search | ✓ | ✓ |
deepseek-vision |
DeepSeek Vision | Vision base model | ✗ | ✗ |
deepseek-vision-reasoner |
DeepSeek Vision Thinking | Vision + deep thinking | ✓ | ✗ |
Notes:
- If DeepSeek introduces new models, the proxy auto-discovers them — no code changes needed
- All models explicitly set
model_type(default/expert/vision) to ensure correct DeepSeek routing- Model names are English-only IDs; Chinese names are in the table above
Tool Calling
DeepSeek's web UI does not support OpenAI function calling format. This proxy implements tool calling via tool prompts and multi-strategy extraction:
curl http://localhost:8000/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "What is the weather in Beijing?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather information",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
}'
Tool prompt
The default prompt asks the model to use this format. Tool passthrough mode allows the model to choose its format:
do: {"name":"search_file","arguments":{"query":"config.yaml"}}
Extraction Strategies
| Priority | Format | Description |
|---|---|---|
| DO | do: {"name":"x","arguments":{}} |
Default prompt format |
| DSML | <|DSML|tool_calls><|DSML|invoke name="X">...</|DSML|invoke></|DSML|tool_calls> |
Compatible format with noise tolerance |
| TOOL_CALL | TOOL_CALL: name(key=value) |
Legacy format fallback |
| JSON | {"name":"x","arguments":{...}} |
JSON block parsing |
| XML | <tool_call><function=NAME>...</function></tool_call> |
Native XML |
| Mixed | <function_call>{...}</function_call> |
XML+JSON |
Fault Tolerance
- Noise tolerance — Supports missing pipes, duplicate
<, fullwidth|, hyphendsml-, and 5 other variants - Fenced code blocks — Automatically skips DSML examples inside markdown code blocks
- JSON repair — Auto-fixes unquoted keys, missing array brackets
- CDATA protection — content/command/prompt parameters retain original strings
- Missing open tags — Auto-restores
<|DSML|tool_calls>wrapper when only closing tag is present
Branch Info
This repository provides two branches:
| Branch | Characteristics |
|---|---|
main (current) |
Full-featured — supports DSML tool calling, streaming sieve, session management, etc. |
no-tools (discontinued) |
Pure chat proxy, no longer maintained — does not receive feature updates or bug fixes |
⚠️ The
no-toolsbranch is discontinued. Use themainbranch instead.
PoW Solver
DeepSeek requires Proof of Work (PoW) verification for the /api/v0/chat/completion endpoint.
Flow
- Before each request, call
POST /api/v0/chat/create_pow_challengeto obtain a challenge - Solve the challenge → get the
x-ds-pow-responseheader - Attach the solve result to the chat request header
Dual Solvers
| Solver | Method | Speed | Compatibility |
|---|---|---|---|
| Node.js WASM | node pow_solver.js subprocess |
Fast (seconds) | Algorithm identical to official |
| Python fallback | hashlib.sha3_256 pure Python |
Slower | Fallback when no Node.js |
Requires Node.js installation + sha3_wasm_bg.wasm file (included in the project).
Algorithm
DeepSeek uses a custom DeepSeekHashV1 algorithm, essentially SHA3-256 hash collision. The WASM version (via Node.js) matches the official algorithm exactly.
Sessions and credentials
Each chat request creates a separate upstream conversation. When credentials expire, the request does not automatically re-login or retry. Re-login in the admin panel or re-import cURL/Cookie credentials. Clients must send the history needed for each request; long histories may still be compressed or trimmed. Newly created upstream conversations are not deleted immediately — they are reclaimed by the cleanup task after they expire (3 days by default).
For password login, the proxy saves and reuses an account-specific device ID and request headers. The admin panel also accepts a manually supplied device ID. Device IDs come from the shared real-device ID pool shipped with the repo; they are not this machine's fingerprint, and these measures do not guarantee protection from account bans.
Management Commands
# Foreground
python3 proxy.py
# Background start
./deploy.sh --bg
# Check status
./deploy.sh --status
# Stop background process
./deploy.sh --stop
# Watch real-time logs (background mode)
tail -f ~/dsapi.log
# Custom port
PROXY_PORT=9000 python3 proxy.py
# Force refresh model list
curl -X POST http://localhost:8000/v1/models/refresh
# Health check
curl http://localhost:8000/health
After Startup:
| Address | Description |
|---|---|
http://localhost:8000/admin |
Web admin panel (login config) |
http://localhost:8000/v1 |
OpenAI compatible API root |
http://localhost:8000/health |
Health check endpoint |
Project Structure
ds-free-api/
├── proxy.py # Main: FastAPI app, SSE parser, OpenAI endpoints, admin panel
├── tool_call.py # Tool calling aggregation (prompt injection, extraction)
├── tool_dsml.py # DSML parser (prefix stripping, CDATA, structured params)
├── tool_sieve.py # Streaming tool call sieve (real-time separation)
├── response_store.py # Responses API local persistence (JSON file)
├── pow_native.py # PoW solver: Node.js WASM primary + Python fallback
├── pow_solver.js # Node.js PoW solve script (calls WASM)
├── sha3_wasm_bg.wasm # SHA3 WASM binary
├── deploy.sh # One-click deploy script (install deps, start/stop/status)
├── requirements.txt # Python dependencies
├── token.example.json # Config file template
├── config.json # Accounts and settings (.gitignore)
└── .secret_key # Encryption key (.gitignore)
Core File Descriptions
| File | Responsibility | Lines |
|---|---|---|
proxy.py |
App entry, routing, SSE parsing, DeepSeek API interaction, token refresh, admin panel UI | ~3770 |
response_store.py |
Responses API local persistence (thread-safe JSON read/write) | ~73 |
pow_native.py |
PoW solver (Node.js subprocess + Python pure algorithm fallback) | ~124 |
deploy.sh |
One-click deploy (env check, dependency install, start/stop/status) | ~198 |
Configuration Reference
Accounts and settings are stored in config.json, with accounts in the accounts list. Sensitive fields including tokens, passwords, cookies, request headers, device IDs and the admin password are encrypted using Fernet. The key is stored in .secret_key in the same directory. Other fields, including account identifiers, are not all encrypted.
Both files are excluded by .gitignore. Restrict access and back them up together; losing or replacing the key prevents existing credentials from being decrypted. On first startup, if config.json is absent, the application attempts to migrate a legacy token.json account and renames that file to token.json.bak. The old file may contain plaintext credentials and should be handled accordingly.
The Docker example uses a persistent volume for both the configuration and key; retain the volume when recreating the container.
Environment variables:
| Variable | Purpose and default |
|---|---|
PROXY_PORT |
Listening port; default 8000 |
DEEPSEEK_PROXY_API_KEY |
/v1 API key; authentication is disabled when unset. Send a Bearer token or x-api-key |
DEEPSEEK_MIN_INTERVAL_SEC |
Minimum start interval for controlled upstream operations; default 2.5 seconds |
DEEPSEEK_MAX_CONCURRENT |
Maximum concurrent controlled upstream operations; default 1 |
DEEPSEEK_ERROR_COOLDOWN_SEC |
Account cooldown after a general error; default 60 seconds |
DEEPSEEK_SESSION_INVALID_COOLDOWN_SEC |
Account cooldown after session invalidation; default 300 seconds |
DEEPSEEK_AUTO_RELOGIN |
Auto-relogin switch, enabled by default; since v2.5.0 every chat request creates a fresh upstream session, so session-invalid responses are no longer auto-relogged — the account is cooled down instead (300s default). Use the admin panel to relogin manually |
DEEPSEEK_SLOT_WAIT_TIMEOUT_SEC |
Max wait for the global upstream slot; default 600 seconds. Returns 503 (session creation / non-stream) on timeout without cooling the account |
DS_STREAM_IDLE_TIMEOUT |
Upstream read-idle limit; default 300 seconds (total duration stays unlimited). Only used when DS_CLIENT_TIMEOUT is unset |
DS_CLIENT_TIMEOUT |
Total upstream request timeout in seconds; default 0 = unlimited. When set, DS_STREAM_IDLE_TIMEOUT no longer applies |
These controls do not cover every upstream operation, such as attachment uploads. For public deployment, set an API key and configure HTTPS and access controls.
Dependencies
Python (pip)
pip install fastapi uvicorn curl-cffi python-dotenv tiktoken cryptography jsonschema
| Dependency | Purpose |
|---|---|
fastapi |
Web framework |
uvicorn |
ASGI server |
curl-cffi |
HTTP client (emulates Chrome TLS fingerprint, bypasses anti-bot) |
python-dotenv |
Environment variable loading |
tiktoken |
Tokenization and usage accounting |
cryptography |
Fernet encryption of sensitive fields in config.json |
jsonschema |
Tool argument schema validation |
System
- Node.js — PoW solver (required, install with
pkg install nodejsorapt install nodejs) - Python 3.10+ — runtime
Limitations & Known Issues
| Limitation | Description |
|---|---|
| Token validity | ~24 hours expiry; re-login or re-import credentials when expired |
| Concurrency limit | DeepSeek free tier limits ~2 concurrent requests per account |
| Chat Completions + Responses only | Embeddings, Fine-tuning, and other endpoints are not supported |
| PoW latency | Each request requires fetching and solving a PoW challenge (Node.js ~1-3 seconds) |
| Non-streaming via SSE | DeepSeek only provides SSE streams; non-streaming requests buffer all SSE events then merge |
| Vision non-streaming | Vision models have no content output in streaming mode; internally uses non-streaming then wraps as SSE |
FAQ
Q: Admin page shows blank after startup?
A: The admin panel is a single-file HTML embedded in proxy.py. Check for JavaScript errors (F12 Console). Make sure you access http://localhost:8000/admin directly.
Q: "Update to the latest version to use Expert/Vision" error?
A: x-client-version must match DeepSeek's web UI version (currently 2.4.2). The proxy sets this automatically at startup.
Q: PoW solving fails?
A: Check if Node.js is installed (node --version). If Node.js solving fails, the proxy automatically falls back to Python pure algorithm solving (slower but no external dependencies).
Q: Wrong password error on login? A: Verify your password is correct. DeepSeek passwords require at least 8 characters with letters + numbers. You may need to complete a captcha first in some cases.
Q: What happens when Token expires? A: Re-login in the admin panel, or re-import credentials for cURL/Cookie accounts.
Q: Specified expert model but conversation appears in "Quick Mode" (default)?
A: Usually caused by expired Token or Session. DeepSeek silently downgrades requests to the default model when credentials are invalid. Solution: re-login with phone/email on the admin panel at http://localhost:8000/admin — the login will auto-refresh both Token and Session.
Q: Can this be deployed on a public server?
A: Set DEEPSEEK_PROXY_API_KEY and configure HTTPS and access controls. When the variable is unset, /v1 does not validate an API key.
License & Credits
MIT License
Reference projects:
- NIyueeE/ds-free-api — Rust original, provided the DeepSeek API reverse-engineering approach and PoW algorithm reference
- CJackHwang/ds2api — DSML tool calling format, streaming sieve architecture, DeepSeek native dialogue markers
- GoblinHonest/mimo2api_mimoapi — Session management design reference
- Acidmoon — Submitted PR #2, implementing the OpenAI Responses API compatibility layer
- xstjmark21-cmyk — Provided model tokens for Vision feature testing