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

@ramsesy/deepseek-local-api

v0.9.0

Published

Convert DeepSeek Web Chat to an OpenAI-compatible local API and interactive CLI for any harness or agent

Readme

DeepSeek Local API & CLI Client (deepseek-local-api)

Convert DeepSeek Web Chat into a zero-overhead, OpenAI-compatible local API server and interactive terminal CLI.


[!IMPORTANT]

🧠 Native Tool Calling Support (v0.9.0+)

  • Zero-Config Tool / Function Calling: When agent harnesses like Hermes, Claude Code, or custom bots pass tools in their requests, the gateway automatically guides DeepSeek, parses tool calls (e.g. write_file, terminal), normalizes local filesystem paths, and streams standard OpenAI delta.tool_calls.
  • The Hands (Your Agent Harness): The agent harness executes the returned tool calls locally and creates files, executes terminal commands, and edits code seamlessly.
  • Install the Official Skill via skills.sh (Vercel):
    npx skills add m-elramsesy/deepseek-local-api --skill delegate-to-deepseek -g
    Registry: skills.sh/m-elramsesy/deepseek-local-api/delegate-to-deepseek

⚡ Quick Start

1. Set Your Token

Obtain your token from chat.deepseek.com:

  1. Sign in to chat.deepseek.com.
  2. Open DevTools (F12), go to Application > Local Storage.
  3. Copy the value of userToken.
  4. Create a .env file in your directory:
    DEEPSEEK_TOKEN="your_token_here"

2. Run Directly with npx

# Start the OpenAI-compatible local server on port 4040
npx @ramsesy/deepseek-local-api -s 4040

# Or launch interactive terminal chat
npx @ramsesy/deepseek-local-api

3. Or Install Globally

npm install -g @ramsesy/deepseek-local-api

# Start local server anywhere:
deepseek -s 4040

🧠 Official Agent Skill: delegate-to-deepseek (skills.sh)

MANDATORY FOR ANY HARNESS OR CODING AGENT When using this local API server with any agent harness (such as Hermes, Claude Code, OpenCode, Cursor, Continue, Antigravity), the agent must have the delegate-to-deepseek skill installed.

📥 One-Line Installation via Vercel's Skills CLI

# Install globally for all your AI agents:
npx skills add m-elramsesy/deepseek-local-api --skill delegate-to-deepseek -g

# Or install specifically for the current project:
npx skills add m-elramsesy/deepseek-local-api --skill delegate-to-deepseek

Skills Registry Listing: https://skills.sh/m-elramsesy/deepseek-local-api/delegate-to-deepseek

🔄 How the Delegation Protocol Works:

  1. Context Packaging (Harness): Your agent gathers existing project files, error logs, or user requirements.
  2. Text Request (Gateway): The agent calls http://localhost:4040/v1/chat/completions (or uses call-deepseek.js).
  3. Deep Synthesis (DeepSeek): DeepSeek R1 / V3 reasons through the problem and generates 100% complete, un-truncated production code.
  4. Tool Execution (Harness): Your agent receives the pure text, extracts the code, and uses its native tools (write_to_file, replace_file_content, run_command) to create the file on disk or Desktop, run tests, and execute commands.

🛠️ Usage Modes

Mode 1: OpenAI-Compatible Local Server

Run a local API server compatible with any OpenAI API client or agent harness:

# Start on localhost (127.0.0.1:4040)
deepseek --server 4040

# Expose to your local network / LAN (0.0.0.0:8080)
deepseek --server 8080 --network

Supported Endpoints:

  • POST http://localhost:4040/v1/chat/completions
    • Supports standard OpenAI payload (model, messages, stream).
    • Supports both Streaming (stream: true via SSE) and Non-Streaming (stream: false).
    • Supports reasoning_content delta for R1 thinking process.
    • Automatic fallback to .env token if client sends placeholder/dummy keys.
    • Full CORS enabled.
  • GET http://localhost:4040/v1/models
    • Returns deepseek-chat and deepseek-reasoner.
  • GET http://localhost:4040/health
    • Health check endpoint.

Mode 2: Interactive Terminal Chat

Run without arguments to start an interactive multi-turn conversation:

deepseek

Interactive Features:

  • Tab Autocomplete: Type / and press Tab to see and autocomplete commands.
  • Arrow-Key Session Picker: Use ↑ / ↓ to select from past saved sessions.
  • Live In-Chat Commands:
    • /help: Display all available commands.
    • /thinking: Toggle reasoning/thinking mode on or off.
    • /search: Toggle web search mode on or off.
    • /server [port]: Launch the local OpenAI-compatible server on the fly.
    • /new: Start a fresh session.
    • /id: Print current session ID and direct web URL.
    • /exit: Quit session.

Mode 3: Single-Turn CLI Prompt

Send a quick prompt and stream the result directly to your terminal:

deepseek "Explain the difference between process.nextTick and setImmediate in Node.js"

Mode 4: Agent Delegation & Direct File Output (call)

Offload heavy code generation directly from your terminal or AI Agent with automatic code extraction:

# Offload file creation to DeepSeek (saves tokens on Gemini/Claude/Hermes!)
deepseek call -p "Create an Express rate limiter middleware with in-memory sliding window" -o ./src/rateLimiter.js

# Or run anywhere via npx (zero installation needed):
npx @ramsesy/deepseek-local-api call -p "Write an async queue worker in TypeScript" -o ./src/queue.ts

# Refactor an existing file using DeepSeek R1 reasoning:
deepseek call -p "Optimize performance and fix memory leaks" -f ./src/dataProcessor.js -m deepseek-reasoner -o ./src/dataProcessor.js

💰 Token Economics: Frontier Models + DeepSeek Subagent

| Model in Your Harness | Challenge | Solution with deepseek-local-api | | :--- | :--- | :--- | | Gemini 2.5 (Antigravity) | High rate-limit & token consumption for 500+ line codebases | Gemini plans the architecture, DeepSeek writes the heavy code (0 tokens). | | Claude 3.7 / Opus (Claude Code) | Expensive output token pricing for large boilerplate files | Claude oversees & audits, DeepSeek generates the raw implementation. | | Hermes / OpenCode | Local / open-source tool execution efficiency | Harness executes write_to_file & tests, DeepSeek handles R1 reasoning. |


🤖 Harness Integration Guide (Hermes, OpenCode, Claude Code, Cursor)

Configure your harness to point to your local endpoint:

Configuration Settings

| Setting | Value | | :--- | :--- | | Base URL | http://localhost:4040/v1 | | API Key | dummy-token (any string; server uses your .env token) | | Models | deepseek-chat or deepseek-reasoner | | Streaming | Enabled (true) |

Bundled CLI Helper for Harnesses:

Harnesses can also directly query the gateway via the zero-dependency script:

node skills/delegate-to-deepseek/scripts/call-deepseek.js \
  --port 4040 \
  --prompt "Create a complete Node.js CLI script for rate-limiting"

📄 License

MIT