High-performance, 100% native Golang OpenAI & Anthropic compatible API relay server (http://localhost:8000) powered by personal DeepSeek Web accounts.
Designed specifically to serve as a fast, reliable drop-in backend provider for Agentic Coding CLIs (e.g., Claude Code, OpenCode, OpenAI Codex CLI, Cursor, Aider, Continue, etc.) with native support for Anthropic Messages API, OpenAI Chat Completions, DeepThink R1 Reasoning, Live Web Search & Citations, and Multi-Turn Agent Trajectory Tool Calling.
- Pure Go WASM PoW Solver (
wazero) β Zero CGo dependencies. Solves DeepSeeksha3_wasm_bg.wasmchallenges natively in ~0.16s. - Dual API Compatibility (Anthropic + OpenAI) β Dual endpoint support for both Anthropic Messages API (
POST /v1/messages) and OpenAI Chat (POST /v1/chat/completions). - Claude Code Integration β Native support for Claude Code CLI and Anthropic SDKs via
/v1/messageswiththinkingblocks (budget_tokens),tool_useJSON objects, andtool_resulthistory. - OpenAI Codex CLI Compatibility β Native discovery schema for
GET /v1/modelsincluding reasoning levels, slug, and context windows. - Auto Token Exchange & Self-Healing β Accepts raw
userTokenfrom LocalStorage, automatically exchanges it for short-livedaccessTokenvia/api/v0/users/current, and auto-refreshes on expiration. - Clean Reasoning Output Parser β Separates
THINKandRESPONSEstream fragments dynamically.reasoning_content&thinkingare delivered in standard delta formats without corrupting main answer text. - Live Web Search & Structured Citations β Supports
deepseek-searchanddeepseek-reasoner-searchwith automatic conversion of[citation:X]tags and structured markdown footnote citations. - Multi-Format Tool Calling & Trajectory Replay β Parses
<tool>...</tool>,<tool:name>,<tool_call>, and<parameter>shapes, while reconstructing multi-turn assistant tool calls andtool_resultoutputs with anchoring instructions to prevent agent amnesia and duplicate calls. - Ephemeral Session Auto-Cleanup β Temporary one-off sessions are automatically deleted from DeepSeek's backend via
/api/v0/chat_session/delete, keeping your web dashboard clean. - CORS & Web Frontend Ready β Built-in CORS middleware and preflight handlers for browser web interfaces (Open WebUI, Chatbox, etc.).
| Endpoint | Standard API | Supported Features |
|---|---|---|
POST /v1/messages |
Anthropic Messages API | Claude Code CLI, Anthropic SDKs, thinking blocks, tool_use, tool_result |
POST /v1/chat/completions |
OpenAI Chat API | OpenCode, Cursor, Aider, reasoning_content, tool_calls, Web Search, SSE Streaming |
GET /v1/models |
OpenAI / Codex Models API | Model Discovery (slug, context_window, supported_reasoning_levels) |
GET /healthz |
Health Endpoint | Server status check ({"status":"ok"}) with CORS headers |
| Model Name / Slug | Mode | Capabilities | Description |
|---|---|---|---|
deepseek-chat / deepseek-v3 |
Fast Chat | Text | Standard high-speed conversational model |
deepseek-reasoner / deepseek-r1 |
Reasoning | Text + DeepThink | Reasoning model streaming reasoning_content deltas |
deepseek-expert |
Expert | Text + DeepThink | High-precision model for complex architecture |
deepseek-search |
Web Search | Text + Live Web Search | Model with real-time internet search and citation links |
deepseek-reasoner-search |
Hybrid | DeepThink + Live Search | DeepThink R1 combined with live internet search |
cmd/serverβ High-performance HTTP server entry point (net/http&log/slog).pkg/powβ WebAssembly PoW solver executingsha3_wasm_bg.wasmviawazero.pkg/authβ Session storage, token extraction, and access token resolution (session/session.json).pkg/clientβ Direct HTTP client driver,/users/currentauto-exchange,/chat_session/deletecleaner, and real-time SSE stream parser.pkg/agenticβ Multi-format tool parser, trajectory prompt replay builder, thinking extractor, and session cache.pkg/serverβ OpenAI & Anthropic REST API handlers (/v1/messages,/v1/chat/completions,/v1/models,/healthz).
- Go 1.22+
- A DeepSeek Account (free account from chat.deepseek.com)
Create session/session.json (or set DEEPSEEK_TOKEN in .env):
{
"token": "YOUR_DEEPSEEK_USER_TOKEN_OR_BEARER",
"cookies": {
"ds_session_id": "YOUR_SESSION_ID"
},
"user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36...",
"captured_at": 1786623559
}π‘ Easy Token Capture:
- Open chat.deepseek.com in your browser and log in.
- Open Developer Tools (F12) β Application β Local Storage β
chat.deepseek.com.- Copy the value of
userToken(raw string or JSON{"value":"..."}).- Paste it into
"token"insession/session.json. The server will handle authentication and auto-refresh automatically!
# Clone the repository
git clone https://github.com/joyccn/Deepseek-API.git
cd Deepseek-API
# Build static binary
CGO_ENABLED=0 go build -o deepseek-api-server ./cmd/server
# Run server (default on http://127.0.0.1:8000)
./deepseek-api-serverexport ANTHROPIC_BASE_URL="http://localhost:8000"
export ANTHROPIC_API_KEY="dummy-token"
export ANTHROPIC_MODEL="claude-3-7-sonnet-20250219"
claude- OpenAI Base URL:
http://localhost:8000/v1 - API Key:
dummy-token - Model:
deepseek-chat,deepseek-reasoner, ordeepseek-search
curl http://localhost:8000/v1/messages \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-7-sonnet-20250219",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Explain quantum computing in 2 sentences."}],
"thinking": {"type": "enabled", "budget_tokens": 1024}
}'curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-search",
"messages": [{"role": "user", "content": "What is the latest release version of Go language in 2026?"}]
}'curl -N http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-reasoner",
"stream": true,
"messages": [{"role": "user", "content": "Solve: 17 * 29 + 143"}]
}'curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-chat",
"messages": [{"role": "user", "content": "What is the weather in Tokyo?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}]
}'Run comprehensive unit tests across all packages:
go test ./... -v -count=1MIT β Open source under the MIT License.
Β© 2026-Present Joy.