DS2API — DeepSeek Web 대화를 OpenAI/Claude/Gemini 호환 API로 바꾸는 Go 미들웨어

DeepSeek Web 채팅 경험을 OpenAI·Claude·Gemini 호환 API로 재노출하는 고성능 Go 풀스택 미들웨어. Vercel Serverless, Docker, 로컬 실행, Linux systemd를 모두 지원하고 관리자 WebUI까지 포함한다.

핵심 요약

  • CJackHwang/ds2api는 DeepSeek Web 대화를 범용 API로 감싼다.
  • 백엔드는 순수 Go, 관리자 UI는 React/Vite WebUI다.
  • 최신 릴리스는 v4.3.0(2026-05-01)이고, 저장소는 약 3K stars, AGPL-3.0이다.
  • /v1/*, /anthropic/*, /v1beta/models/*, /admin/*를 하나의 HTTP surface로 묶는다.
  • 다중 계정 회전, token refresh, in-flight 큐 제어, DeepSeek PoW, tool calling, 운영용 probes가 핵심이다.

왜 중요한가

  • 모델 자체보다 모델 접근 계층이 제품화되는 흐름의 예시다.
  • Claude Code Router, openai-oauth, free-claude-code처럼 “모델을 쓰는 방법”을 서비스 레이어로 포장한다.
  • DeepSeek 전용 웹 경험을 범용 API로 바꾸기 때문에, 클라이언트/프로토콜 호환 레이어를 빠르게 붙일 수 있다.

아키텍처 요약

  • Backend: Go (cmd/ds2api/, api/, internal/), Python runtime 없음
  • Frontend: React WebUI (webui/), 배포 시 static/admin으로 빌드
  • Routing: chi router tree 아래 OpenAI / Claude / Gemini / Admin / WebUI 공존
  • Execution: Claude/Gemini 요청을 내부 공용 핵심으로 정규화한 뒤 다시 원래 프로토콜로 렌더링
  • Tool calling: Go와 Vercel Node runtime이 같은 anti-leak / incremental semantics를 맞춘다

핵심 기능

  • OpenAI 호환: /v1/models, /v1/chat/completions, /v1/responses, /v1/embeddings, /v1/files
  • Claude 호환: /anthropic/v1/models, /anthropic/v1/messages, /anthropic/v1/messages/count_tokens
  • Gemini 호환: /v1beta/models/{model}:generateContent, /v1beta/models/{model}:streamGenerateContent
  • 다중 계정 회전과 자동 token refresh
  • 계정별 in-flight 제한 + 대기열
  • DeepSeek PoW: DeepSeekHashV1 순수 Go 구현
  • Tool Calling: 비코드블록 신호 추출, early delta.tool_calls, incremental output
  • Admin API: 설정, account/proxy 관리, session cleanup, import/export, Vercel sync, version check
  • WebUI 관리자 패널: bilingual, dark mode, server-side conversation viewer
  • Health probes: /healthz, /readyz

4.x에서 바뀐 점

  • internal/adapter/* 중심 구조가 internal/httpapi/* 중심으로 재편됐다.
  • internal/deepseek/client/, protocol/, transport/로 쪼개졌다.
  • 새 모듈로 internal/promptcompat/, internal/toolstream/, internal/chathistory/가 추가됐다.
  • Claude/Gemini 요청은 internal/translatorcliproxy를 거쳐 공용 실행 경로로 흘러간다.
  • docs/prompt-compatibility.md가 API → pure-text web-chat context 정규화의 사실상 source of truth 역할을 한다.

릴리스 메모: v4.3.0

  • history context 처리 로직 개선
  • 비-UTF-8 입력 거부 시도와 출력 제한 강화
  • Vercel 라우팅 업데이트
  • vision 모드 완전 호환 적응
  • tool-call 신뢰성 및 성능 개선

배포/운영 메모

  • README 기준으로 Vercel, Docker, systemd, 로컬 실행을 모두 커버한다.
  • 인증은 managed key mode와 direct token mode를 지원한다.
  • /admin/version, /admin/dev/captures 같은 운영면이 있어서 디버깅 루프를 닫기 쉽다.

Sources