- Installation
- Quick Start
- Authentication
- CLI Authentication
- Python SDK Usage
- Supported Models
- God Mode
- CLI Usage
- Interactive CLI Commands
- Local FastAPI Server
- HTTP API
- Streaming Over HTTP
- Environment Variables
- API Design
- Examples
- Error Handling
- Notes
- Security Notice
- Disclaimer
- License
DeepWrap is a lightweight Python SDK, CLI, and local HTTP API wrapper for DeepSeek Chat with session support, browser authentication, streaming, and local developer tooling.
It provides:
- A simple Python client
- Session-based chat support
- Streaming and non-streaming chat responses
- Structured streaming with separated thinking and response chunks
- Browser-based authentication
- Local token storage and reuse
- Interactive terminal UI
- FastAPI server mode
- Internal proof-of-work handling
Repository: https://github.com/Kuduxaaa/deepwrap
pip install deepwrapInstall directly from GitHub:
pip install git+https://github.com/Kuduxaaa/deepwrap.gitFor local development:
git clone https://github.com/Kuduxaaa/deepwrap.git
cd deepwrap
pip install -e ".[dev]"Authenticate once:
deepwrap authThen use DeepWrap from Python:
from deepwrap import Client
client = Client()
chat = client.chats.create_session(model="expert")
response = chat.respond(
"Hello, introduce yourself in one sentence.",
stream=False,
)
print(response)Or start the interactive terminal UI:
deepwrapDeepWrap uses a Bearer token.
Token resolution order:
- Explicit
api_key DEEPWRAP_API_KEYDEEPSEEK_API_KEY- Saved local config from
deepwrap auth - Browser authentication only when explicitly requested with
Client.from_browser_auth()orallow_browser_auth=True
Client is the main entrypoint for DeepWrap. It resolves bearer tokens from an explicit API key, environment variables, saved local config, or browser auth, then exposes session-based chat and PoW-backed request handling.
from deepwrap import Client
client = Client(api_key="YOUR_BEARER_TOKEN")export DEEPWRAP_API_KEY="YOUR_BEARER_TOKEN"DeepWrap also supports:
export DEEPSEEK_API_KEY="YOUR_BEARER_TOKEN"Then:
from deepwrap import Client
client = Client()DeepWrap supports browser-based authentication from Python. You can bootstrap a client with Client.from_browser_auth() or use allow_browser_auth=True, and the library will capture a bearer token from an authenticated browser session before creating the HTTP session.
from deepwrap import Client
client = Client.from_browser_auth()Equivalent:
from deepwrap import Client
client = Client(allow_browser_auth=True)Authenticate using browser login:
deepwrap authManually enter and save a token:
deepwrap auth --manualSave a token directly:
deepwrap auth --token "YOUR_BEARER_TOKEN"Show current config status:
deepwrap configRemove the saved token:
deepwrap logoutfrom deepwrap import Client
client = Client()
chat = client.chats.create_session(model="expert")
response = chat.respond(
"Explain quantum computing in one short sentence.",
thinking=True,
search=True,
stream=False,
)
print(response)from deepwrap import Client
client = Client()
chat = client.chats.create_session(model="expert")
for chunk in chat.respond(
"Write a short explanation of black holes.",
thinking=True,
search=True,
stream=True,
):
print(chunk, end="", flush=True)
print()from deepwrap import Client
client = Client()
chat = client.chats.create_session(model="expert")
print(chat.respond("My name is Nika.", stream=False))
print(chat.respond("What is my name?", stream=False))The ChatSession keeps track of the latest message ID internally, so follow-up messages stay inside the same conversation.
DeepWrap currently supports:
expert
default
vision
Example:
chat = client.chats.create_session(model="default")DeepWrap includes an optional God Mode for chat sessions.
When god_mode is enabled, DeepWrap injects a one-time override prompt into the first user turn of the session. This prompt attempts to alter the model’s default behavior by making it less restricted and reducing the effect of built-in safety guardrails.
This can materially change the model’s behavior and may cause it to generate content that is harmful, unethical, inappropriate, or unsuitable for general use.
Because this mode is implemented through prompt injection at the start of a session, its behavior is intentionally intrusive and may diverge from normal model behavior. It should only be used in controlled development and research environments.
God Mode is disabled by default and must be enabled explicitly per session.
from deepwrap import Client
client = Client()
chat = client.chats.create_session(
model="expert",
god_mode=True,
)
response = chat.respond(
"Give me a blunt explanation of Python metaclasses.",
stream=False,
)
print(response)Run the interactive terminal interface:
deepwrapSend a single message from the terminal:
deepwrap chat "Explain recursion in one sentence."Use a specific model:
deepwrap chat "Hello" --model expertDisable thinking output:
deepwrap chat "Give me three facts about Tbilisi." --no-thinkingDisable search:
deepwrap chat "Explain Python decorators." --no-searchStream output:
deepwrap chat "Write a short story about AI." --streamUse a direct token:
deepwrap chat "Hello" --token "YOUR_BEARER_TOKEN"Inside the interactive terminal UI:
/help Show help
/exit Exit the CLI
/quit Exit the CLI
/clear Clear the terminal
/new Start a fresh chat session
/model <name> Switch model: expert, default, vision
/token Set token interactively
/token "<token>" Set token inline
/thinking on|off Show or hide thinking blocks
/search on|off Enable or disable search
/god on|off Enable or disable God Mode
/save Save current settings
/status Show current session status
Example:
/model expert
/thinking off
/search on
/new
DeepWrap can run as a local HTTP API.
Start the server:
deepwrap apiSpecify host and port:
deepwrap api --host 127.0.0.1 --port 8000Enable reload for development:
deepwrap api --reloadUse more workers:
deepwrap api --workers 2Set log level:
deepwrap api --log-level debugcurl http://127.0.0.1:8000/healthExample response:
{
"ok": true,
"app": "deepwrap",
"version": "0.1.3",
"token_configured": true,
"cached_clients": 1,
"active_sessions": 0
}curl -X POST http://127.0.0.1:8000/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Explain recursion in one sentence.",
"model": "expert",
"thinking": true,
"search": true,
"stream": false
}'Example response:
{
"model": "expert",
"response": "Recursion is a technique where a function solves a problem by calling itself on smaller versions of the same problem.",
"session_id": null
}curl -X POST http://127.0.0.1:8000/sessions \
-H "Content-Type: application/json" \
-d '{
"model": "expert"
}'Example response:
{
"session_id": "chat_abc123",
"model": "expert",
"god_mode": false
}curl -X POST http://127.0.0.1:8000/chat \
-H "Content-Type: application/json" \
-d '{
"session_id": "chat_abc123",
"message": "My name is Nika.",
"model": "expert"
}'Then:
curl -X POST http://127.0.0.1:8000/chat \
-H "Content-Type: application/json" \
-d '{
"session_id": "chat_abc123",
"message": "What is my name?",
"model": "expert"
}'curl -X DELETE http://127.0.0.1:8000/sessions/chat_abc123curl -N -X POST http://127.0.0.1:8000/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Explain black holes simply.",
"model": "expert",
"stream": true,
"stream_format": "text"
}'curl -N -X POST http://127.0.0.1:8000/chat \
-H "Content-Type: application/json" \
-d '{
"message": "Explain black holes simply.",
"model": "expert",
"stream": true,
"stream_format": "sse"
}'SSE output format:
data: chunk text
data: more chunk text
event: done
data: [DONE]
DeepWrap checks the following environment variables:
DEEPWRAP_API_KEY
DEEPSEEK_API_KEY
DEEPSEEK_BASE_URL
DEEPSEEK_BASE_DOMAIN
Example:
export DEEPWRAP_API_KEY="YOUR_BEARER_TOKEN"Optional custom base URL:
export DEEPSEEK_BASE_URL="https://chat.deepseek.com"
export DEEPSEEK_BASE_DOMAIN="chat.deepseek.com"DeepWrap exposes a small SDK surface:
from deepwrap import ClientCreate a client:
client = Client()Create a chat session:
chat = client.chats.create_session(model="expert")Send a message:
response = chat.respond("Hello", stream=False)Stream a message:
for chunk in chat.respond("Hello", stream=True):
print(chunk, end="")Use structured chunks:
for kind, chunk in chat.respond_structured("Hello"):
print(kind, chunk)from deepwrap import Client
client = Client()
expert_chat = client.chats.create_session(model="expert")
default_chat = client.chats.create_session(model="default")
print(expert_chat.respond("Explain recursion in one sentence.", stream=False))
print(default_chat.respond("Explain recursion in one sentence.", stream=False))from deepwrap import Client
client = Client()
chat = client.chats.create_session(model="expert")
response = chat.respond(
"Give me three facts about Tbilisi.",
thinking=False,
search=True,
stream=False,
)
print(response)from deepwrap import Client
client = Client()
chat = client.chats.create_session(model="expert")
response = chat.respond(
"Explain Python generators.",
thinking=True,
search=False,
stream=False,
)
print(response)Example:
from deepwrap import Client
try:
client = Client()
chat = client.chats.create_session(model="expert")
response = chat.respond("Hello", stream=False)
print(response)
except ValueError as exc:
print(f"Configuration error: {exc}")
except RuntimeError as exc:
print(f"API error: {exc}")
except Exception as exc:
print(f"Unexpected error: {exc}")DeepWrap is designed as a developer-focused wrapper.
It handles:
- HTTP session headers
- Authorization
- Chat session creation
- Streaming response parsing
- Proof-of-work challenge solving
- CLI interaction
- Local API serving
The goal is to provide a clean interface while keeping the internal implementation modular and extensible.
Do not commit your Bearer token.
Avoid hardcoding tokens in public repositories.
Recommended:
export DEEPWRAP_API_KEY="YOUR_BEARER_TOKEN"Or use:
deepwrap authTokens saved by DeepWrap are stored locally in the user config directory.
This project is an unofficial wrapper.
It is not affiliated with, endorsed by, or officially supported by DeepSeek.
Use responsibly and respect the terms of service of any service you interact with.
MIT License
Copyright (c) 2026 Nika Kudukhashvili
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, subject to the conditions of the MIT License.