Skip to content

SamuelMaiko/DeepRouter

Repository files navigation

DeepRouter

A Django-based proxy router for DeepSeek with API keys dashboard and OpenAI-compatible interface. Create an account or setup locally to use.

Features

  • OpenAI-Compatible Interface: Fully drop-in compatible with standard OpenAI SDKs (Python, Node.js, and cURL).
  • Unified Developer Dashboard:
    • Secure API key generation, status toggling, and deletion.
    • Real-time request volume analytics powered by ApexCharts.
    • Clean API Request Logging (tracks latency, endpoints, status codes, and estimated tokens).
  • Interactive Docs & Playground:
    • Live JSON Request Body playground.
    • Real-time client code snippet updates (Python, Node.js, and cURL) as you edit parameters.
    • Prism.js syntax highlighting for all blocks.
  • Session Threading: Maintains conversation context automatically across stateless API calls when a session_id is supplied.
  • Models Support: Fully supports deepseek-chat and deepseek-reasoner (R1) with token-by-token streaming, reasoning processes, and web search configurations.

Installation & Setup

1. Clone the Repository

git clone https://github.com/izaart95-jpg/DeepRouter.git
cd DeepRouter

2. Set Up Virtual Environment & Dependencies

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt

3. Configure Environment Variables

Create a .env file by copying the example template:

cp .env.example .env

Edit .env to configure your SECRET_KEY and database settings.

For PostgreSQL / MySQL / other external databases, configure the split DB variables:

DB_ENGINE=django.db.backends.postgresql  # or django.db.backends.mysql
DB_NAME=your_db_name
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=your_db_host
DB_PORT=5432
# PostgreSQL SSL settings (optional)
DB_SSLMODE=require

If these variables are omitted, DeepRouter will automatically fallback to SQLite.

4. Database Setup & Server Execution

Apply migrations to set up database schemas for keys and request logs:

python manage.py migrate
python manage.py runserver

The server will start at http://127.0.0.1:8000/.

5. Create Superuser & Configure DeepSeek Token

To routing requests successfully, you must configure a valid DeepSeek account token:

  1. Create a Django Superuser:
    python manage.py createsuperuser
  2. Access the Django Admin: Navigate to http://127.0.0.1:8000/admin/ and log in with the superuser credentials.
  3. Obtain your DeepSeek Token:
    • Go to chat.deepseek.com and log in.
    • Open browser DevTools (F12 or right-click -> Inspect), then select the Console tab.
    • Run the following code snippet and copy the returned string value:
      JSON.parse(localStorage.getItem("userToken")).value
  4. Register the Token:
    • In the Django Admin, go to Deep seek tokens -> Add deep seek token.
    • Paste the copied token value into the form field, ensure Is active is checked, and click Save.

API Reference

The router endpoints are accessible at http://127.0.0.1:8000/api/v1.

POST /api/v1/chat/completions

Headers:

  • Content-Type: application/json
  • Authorization: Bearer ds-live-YOUR_API_KEY (Generate this from your dashboard keys tab)

Request Parameters:

  • model (string, required): deepseek-chat or deepseek-reasoner.
  • messages (array, required): Array of message objects (role & content).
  • stream (boolean, optional): Set to true to enable SSE streaming.
  • session_id (string, optional): A unique session ID to enable stateful conversation history tracking.
  • thinking (boolean, optional): Toggle model reasoning processes where supported.
  • search (boolean, optional): Toggle web search integration.

Acknowledgements

About

Deepseek Free OpenAI compatible APIs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors