Skip to content

Repository files navigation

Unofficial API Gateway

⚠️ Unofficial & Experimental

This project uses undocumented, unofficial APIs from DeepSeek and Google (Gemini). These are not officially supported by any provider.

  • APIs can break or change without notice
  • Rate limits and throttling apply
  • Credentials (tokens/cookies) expire and must be refreshed
  • Not affiliated with DeepSeek or Google
  • For prototypes, research, and personal projects only

OpenAI-compatible REST API for DeepSeek and Gemini with multi-profile dynamic load balancing and Web Management Dashboard.

📖 Architecture Overview — project structure, lifecycle, client types, streaming, auth, Docker

🔄 Provider Conversion Details — OpenAI field mapping per provider

🔑 Authentication & Session Management — API key management, Swagger UI setup, conversation context isolation

Quick Start

1. Configure Environment

cp .env.example .env

2. Run Application

Via Docker (Recommended):

docker compose up -d

Via Local Script:

./run.sh

3. Access Services

ProviderGitHub RepositoryCredentials GuideSpecific Endpoints
DeepSeek2noScript/deepseek-apidocs/deepseek.mdreasoning_content
Gemini2noScript/Gemini-APIdocs/gemini.mdChats, Gems, Deep Research

Profiles & Load Balancing

Credentials are stored and managed via Profiles saved in data/profiles.json (or managed dynamically via the Web Dashboard / REST API).

  • Multi-Profile Load Balancing: Chat completion requests automatically load-balance across active profiles (is_active: true) using a Round-Robin algorithm.
  • Session-Profile Sticky Affinity: When passing X-Session-Id, the conversation binds to a specific profile to ensure multi-turn context continuity. If the profile becomes inactive, auto-failover seamlessly routes to another active profile.

Profiles API (/v1/profiles)

EndpointMethodDescription
POST /v1/profilesPOSTCreate a new profile (deepseek requires token, gemini requires cookie)
GET /v1/profilesGETList all profiles (optional query parameter ?type=deepseek or ?type=gemini)
GET /v1/profiles/{id}GETGet profile details by ID
PUT /v1/profiles/{id}PUTUpdate profile name, credentials, or is_active status
DELETE /v1/profiles/{id}DELETEDelete a profile by ID

Configuration

Env varRequiredDescription
UNOFFICIAL_API_DATA_DIRDirectory for profiles.json, api_keys.json, sessions.json. Default: data
DISABLE_AUTHDisable API key authentication in development mode (true/false). Default: true
SESSION_TTL_DAYSSession lifetime in days after last use. 0 = never expire. Default: 7
SESSION_MAX_SESSIONSMax sessions kept in memory. Default: 5000
API_KEY_SECRETHMAC secret for API key signing. Change in production.

Common (OpenAI-compatible) Endpoints

These share the same format across all providers.

EndpointMethodDeepSeekGemini
GET /v1/{provider}/modelsGET
POST /v1/{provider}/chat/completionsPOST

Request body

FieldTypeRequiredDefaultDescription
modelstringModel ID (e.g. deepseek-v3, deepseek-r1, gemini-3-flash, gemini-3-pro)
messagesarray[{"role": "user", "content": "..."}]
streamboolfalseEnable SSE streaming

Response

{
"id": "chatcmpl-1719000000",
"object": "chat.completion",
"created": 1719000000,
"model": "deepseek-v3",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "..." },
"finish_reason": "stop"
}
],
"usage": { "prompt_tokens": 0, "completion_tokens": 42, "total_tokens": 42 }
}

Streaming SSE format:

data: {"choices": [{"delta": {"content": "..."}}]}
data: [DONE]

System

EndpointMethodDescription
GET /healthGETProvider connection status
GET /GETRedirects to Web Dashboard or Swagger UI

API Key Management

EndpointMethodDescription
POST /v1/keys/generatePOSTGenerate a new API key
GET /v1/keysGETList all API keys (masked)
POST /v1/keys/revokePOSTDeactivate an API key

See docs/auth.md for full details.

Examples

# DeepSeek
curl -s http://localhost:8088/v1/deepseek/chat/completions \
-H "Authorization: Bearer <key>" \
-H "Content-Type: application/json" \
-d '{"model": "deepseek-v3", "messages": [{"role": "user", "content": "Hi"}]}'# Gemini
curl -s http://localhost:8088/v1/gemini/chat/completions \
-H "Authorization: Bearer <key>" \
-H "Content-Type: application/json" \
-d '{"model": "gemini-3-flash", "messages": [{"role": "user", "content": "Hi"}]}'# Session persistence with Sticky Profile Affinity
curl -s http://localhost:8088/v1/gemini/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Session-Id: my-chat-session-001" \
-H "Content-Type: application/json" \
-d '{"model": "gemini-3-flash", "messages": [{"role": "user", "content": "What did I just ask?"}]}'

Releases

Packages

Contributors

Languages