npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@deepseek-router/core

v1.0.12

Published

Production-grade multi-provider proxy for Claude Code — DeepSeek, Kimi, Qwen, Zhipu with circuit breaker and automatic failover

Readme

DeepSeek Router


⚡ Quick Start

一键安装(推荐)

摸鱼 (Moyu) — $9 开箱即用

unzip cc-china-stack-*.zip && cd cc-china-stack
bash setup.sh
export DEEPSEEK_API_KEY="sk-your-key"
claude

不用写配置、不用配代理、不用理解什么是 failover。一个脚本搞定。


手动安装(免费)

git clone https://github.com/Cgagm/deepseek-router.git
cd deepseek-router
pnpm install && pnpm run build
cp router.config.example.json router.config.json
export ANTHROPIC_BASE_URL="http://localhost:8788/v1/messages"
claude

Done. Claude Code now routes through 5 providers. If one fails, the next takes over. You won't even notice.


💡 Why DeepSeek Router?

The Problem

Claude Code is the best AI coding tool on the planet. But it talks to one API endpoint. When that endpoint goes down — and it will — your conversation dies mid-sentence. Context lost. Work gone. Rage ensues.

The Solution

DeepSeek Router sits between Claude Code and 5 independent AI providers. When one fails, another takes over automatically. Your request never drops. Your conversation never dies.

Without DeepSeek Router

Claude Code  →  Provider A
                      ↓
                  500 ERROR
                      ↓
              💀 Dead. Context lost.

With DeepSeek Router

Claude Code  →  Router  →  Provider A (fail)
                      ↓
                   Provider B (fail)
                      ↓
                   Provider C ✓
                      ↓
              🎯 Response returned.

What You Get

| Feature | Without Router | With Router | |---------|:-------------:|:-----------:| | Uptime | ~99.5% (single provider) | ~99.99% (5 providers) | | Failover | ❌ Manual | ✅ Automatic, <1ms | | Provider choice | 1 | 5 (DeepSeek, Tencent, Zhipu, Alibaba, ByteDance) | | Cost control | Fixed pricing | Shop across providers | | Circuit breaking | ❌ | ✅ Prevents cascading failures | | Health monitoring | ❌ | ✅ Real-time dashboard | | Hot reload | ❌ | ✅ No restart on config change | | API format | Provider-specific | Anthropic Messages API (works with Claude Code) |


🌐 Providers

All major Chinese AI providers. Mix and match. Pay only for what you use.

| Provider | Model | ~Price (1M tokens) | Format | |----------|-------|:------------------:|--------| | DeepSeek | deepseek-chat | $0.14 | Native Anthropic | | Tencent Hunyuan | hunyuan-lite | $0.14 | OpenAI | | Zhipu GLM | glm-4-flash | $0.14 | OpenAI | | Alibaba Bailian | qwen-turbo | $0.11 | OpenAI | | ByteDance Volcengine | doubao-lite | $0.11 | OpenAI |

~$0.11–$0.14 per MILLION tokens. Claude Code's typical daily usage costs pennies.

Setup guides for each provider →


📊 Benchmarks

Scenario: Provider A rate-limits during a 10-message coding session

Without Router:
  Message 1-5: ✓
  Message 6:   429 → 💀 Session dead. Start over.

With DeepSeek Router:
  Message 1-5:  Provider A ✓
  Message 6:    Provider A 429 → Provider B ✓
  Message 7-10: Provider B ✓
  Result:       Session complete. Nothing lost.

Overhead: <1ms routing decision. Zero impact on response latency.

🏗 Architecture

POST /v1/messages
       │
       ▼
┌─────────────────┐
│   Rate Limiter  │  ← per-IP token bucket (60 req/min)
└────────┬────────┘
         ▼
┌─────────────────┐
│  Zod Validation │  ← strict request schema, 400 on invalid
└────────┬────────┘
         ▼
┌─────────────────┐
│ Failover Router │  ← priority chain, skips open circuits
└────────┬────────┘
         ▼
┌─────────────────┐
│ Circuit Breaker │  ← Closed → Open → HalfOpen → Closed
└────────┬────────┘
         ▼
┌─────────────────┐
│ Format Adapter  │  ← Anthropic ↔ OpenAI translation
└────────┬────────┘
         ▼
┌─────────────────┐
│    Provider     │  ← HTTP request with AbortSignal timeout
└─────────────────┘

📡 API

POST /v1/messages

Anthropic Messages API — drop-in replacement for api.anthropic.com.

curl http://localhost:8788/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: any-value" \
  -d '{
    "model": "deepseek-v4-flash",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Supports: system, stream (SSE), tools, tool_choice, stop_sequences, temperature, top_p, top_k.

GET /health — JSON health report

{
  "status": "healthy",
  "uptime": 3600,
  "version": "1.0.0",
  "providers": [...],
  "summary": { "total": 5, "healthy": 5, "degraded": 0, "down": 0 }
}

GET /metrics — Prometheus format

Compatible with Grafana, Datadog, VictoriaMetrics.

GET / — Human-readable status page


🔧 Configuration

Edit router.config.json. Changes take effect within seconds — no restart needed.

{
  "providers": [
    {
      "name": "deepseek",
      "endpoint": "https://api.deepseek.com/anthropic/messages",
      "apiKey": "$DEEPSEEK_API_KEY",    // env var interpolation
      "format": "anthropic",
      "authType": "x-api-key"
    }
  ],
  "router": {
    "providerOrder": ["deepseek", "tencent", "zhipu", "aliyun", "volcengine"],
    "port": 8788,
    "apiKey": "",                       // set to protect your router
    "circuitBreaker": {
      "failureThreshold": 5,
      "resetTimeoutMs": 30000
    }
  }
}

Full example with comments: router.config.example.json


🔒 Security

  • Auth: Optional API key protection on all endpoints (Authorization: Bearer or x-api-key)
  • Error sanitization: Provider API keys never leak to clients — errors return HTTP 502, not raw upstream bodies
  • HTTPS-only: Config enforces HTTPS endpoints. HTTP not accepted.
  • Header injection prevention: Custom headers validated against CRLF and reserved names
  • Zod validation: Every request body is strictly validated before reaching providers
  • Rate limiting: Per-IP token bucket (default: 60 req/min, 10 concurrent)

🧪 Quality

TypeScript strict mode  ·  158 tests  ·  CI on Node 18/22/24  ·  Vitest  ·  Docker

📦 Install Options

Option 1: Docker (recommended)

docker run -d -p 8788:8788 \
  -v ./router.config.json:/app/router.config.json \
  ghcr.io/Cgagm/deepseek-router:v1.0

Docker Hub →

Option 2: npm

npm install @deepseek-router/core

Option 3: Git

git clone https://github.com/Cgagm/deepseek-router.git
cd deepseek-router && pnpm install && pnpm run build

❓ FAQ

Q: Does this replace Claude API? No. It's a proxy. You still need API keys from the AI providers. The router makes them speak Anthropic's format and handles failover.

Q: How many providers do I need? At least 2 for failover. All 5 for maximum reliability.

Q: What's the latency overhead? <1ms. The router only makes routing decisions. Response data is passthrough.

Q: Can I use this commercially? Yes. MIT license. Build it into your product, sell it as a service — whatever you want.

Q: Why not use the official Claude API directly? You can! But if Anthropic has an outage (it happens), your work stops. This adds 4 backup paths for pennies a day.

Q: How is this different from claude-code-router? claude-code-router is great (34K+ stars), but it has no circuit breaking or automatic failover. If a provider fails, your request fails. DeepSeek Router was built for one thing: your request always succeeds.


⭐ Star History

If this project saves you from losing a single coding session, consider giving it a star.


License

MIT © Chen Gang