ccswitch-deepseek  by liuzhengming

LLM API protocol adapter

Created 1 month ago
274 stars

Top 94.3% on SourcePulse

GitHubView on GitHub
Project Summary

This project offers a protocol translation proxy that enables clients designed for OpenAI's API (specifically the Codex CLI) to seamlessly interact with DeepSeek models. It addresses the incompatibility between OpenAI's Responses API protocol and DeepSeek's Chat Completions API by running a local agent that translates requests and responses, allowing users to leverage DeepSeek's capabilities with existing OpenAI-compatible tooling.

How It Works

The system operates as a local HTTP server that intercepts API calls. It translates input requests from the OpenAI Responses API format to DeepSeek's Chat Completions API format using lib/translate.js. For streaming responses, lib/sse.js handles the translation from DeepSeek's output back to SSE events. A key feature is lib/recover.js, which implements automatic memory and re-injection of reasoning_content across conversational turns to maintain context.

Quick Start & Requirements

  • Installation: Requires Node.js (LTS version recommended). Install project dependencies using npm install in the project directory.
  • Configuration: Copy env_example to .env and set your DeepSeek API key (api_key=sk-your-deepseek-api-key).
  • Running: Start the service with npm start. Clients like Codex CLI will then automatically route through this proxy.
  • Prerequisites: Node.js LTS.

Highlighted Details

  • Supports translation for various input types including text messages, function calls, tool calls, and image inputs (multimodal).
  • Translates output formats, including SSE events, and handles token usage statistics.
  • Passes through common API parameters such as temperature, top_p, max_output_tokens, tools, and tool_choice.
  • Includes 33 unit tests for translation logic that do not require network access.

Maintenance & Community

No specific details regarding maintainers, community channels (like Discord/Slack), or roadmaps are provided in the README.

Licensing & Compatibility

  • License: ISC License.
  • Compatibility: Designed for compatibility with clients adhering to the OpenAI API protocol, enabling straightforward integration with DeepSeek models.

Limitations & Caveats

The proxy explicitly skips translation for input_file and input_audio data types. The mechanism for reasoning_content re-injection relies on automatic memory, which may have edge cases or limitations in complex conversational flows.

Health Check
Last Commit

2 weeks ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
8
Star History
204 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.