Skip to content

feat: deepseek claude endpoint - #1832

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/deepseek-claude-code
Sep 18, 2025
Merged

feat: deepseek claude endpoint#1832
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/deepseek-claude-code

Conversation

@seefs001

@seefs001 seefs001 commented Sep 18, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features
    • Added support for Claude models in the relay, enabling requests and responses through the Claude pathway.
  • Refactor
    • Improved request routing to select the correct endpoints based on format and mode, preserving existing beta handling for non-Claude paths.
  • Bug Fixes
    • Resolved inconsistencies in endpoint selection to reduce failed or misrouted requests when switching between completions and chat-completions.

@coderabbitai

coderabbitai Bot commented Sep 18, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Added Claude adaptor support in deepseek channel. ConvertClaudeRequest now uses claude.Adaptor. Request URL construction branches by RelayFormat: Claude routes to /anthropic/v1/messages; non-Claude preserves beta handling and selects /completions or /v1/chat/completions based on RelayMode.

Changes

Cohort / File(s) Summary of changes
DeepSeek adaptor updates
relay/channel/deepseek/adaptor.go
Updated imports (added gin-gonic/gin and claude packages; removed duplicate gin). ConvertClaudeRequest now delegates to claude.Adaptor. GetRequestURL refactored to branch on RelayFormat: Claude -> .../anthropic/v1/messages; else ensure /beta suffix when needed, then choose .../completions or .../v1/chat/completions based on RelayMode.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant DeepSeekAdaptor as DeepSeek Adaptor
  participant ClaudeAdaptor as Claude Adaptor
  participant OpenAIAdaptor as OpenAI Adaptor
  participant Channel as Channel API

  Client->>DeepSeekAdaptor: Request (RelayFormat, RelayMode, BaseURL)
  alt RelayFormat == Claude
    DeepSeekAdaptor->>ClaudeAdaptor: ConvertClaudeRequest(...)
    Note over DeepSeekAdaptor: URL = BaseURL + "/anthropic/v1/messages"
    DeepSeekAdaptor->>Channel: POST /anthropic/v1/messages
  else Non-Claude
    DeepSeekAdaptor->>OpenAIAdaptor: Convert request (existing path)
    Note over DeepSeekAdaptor: Ensure BaseURL ends with "/beta" when needed
    alt RelayMode == Completions
      DeepSeekAdaptor->>Channel: POST .../beta/completions
    else Chat Completions
      DeepSeekAdaptor->>Channel: POST /v1/chat/completions
    end
  end
  Channel-->>DeepSeekAdaptor: Response
  DeepSeekAdaptor-->>Client: Relay response
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • Calcium-Ion

Poem

A twitch of whiskers, ears held high,
I mapped new paths where packets fly.
Claude hops left, DeepSeek right—
URLs align, the routes feel light.
With gentle paws, I nudge the streams,
And burrow back to coding dreams. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: deepseek claude endpoint" is concise, uses a conventional commit prefix, and accurately summarizes the primary change in the diff (adding Claude/Anthropic support and routing for the deepseek channel); it directly relates to the adaptor and URL construction changes in the changeset. This makes the PR intent clear to reviewers without noisy detail.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
relay/channel/deepseek/adaptor.go (1)

54-59: Consider the URL construction logic for consistency.

The URL construction logic has an inconsistency: for RelayModeCompletions, it uses fimBaseUrl (with /beta appended), but for the default case, it uses info.ChannelBaseUrl directly. This could lead to different behavior depending on the relay mode.

Consider making the URL construction more consistent:

 	switch info.RelayMode {
 	case constant.RelayModeCompletions:
 		return fmt.Sprintf("%s/completions", fimBaseUrl), nil
 	default:
-		return fmt.Sprintf("%s/v1/chat/completions", info.ChannelBaseUrl), nil
+		return fmt.Sprintf("%s/v1/chat/completions", fimBaseUrl), nil
 	}

Or if the beta URL is only needed for completions mode, add a comment explaining this behavior.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 08638b1 and 23ee0fc.

📒 Files selected for processing (1)
  • relay/channel/deepseek/adaptor.go (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
relay/channel/deepseek/adaptor.go (4)
relay/channel/openai/adaptor.go (1)
  • Adaptor (32-35)
relay/channel/claude/adaptor.go (1)
  • Adaptor (23-25)
types/relay_format.go (2)
  • RelayFormat (3-3)
  • RelayFormatClaude (7-7)
relay/constant/relay_mode.go (1)
  • RelayModeCompletions (11-11)

@Calcium-Ion
Calcium-Ion merged commit daf3ef9 into QuantumNous:main Sep 18, 2025
1 check passed
@coderabbitai coderabbitai Bot mentioned this pull request Dec 11, 2025
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
…aude-code

feat: deepseek claude endpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants