Skip to content

fix(v1/messages): reverse-translate OpenAI->Claude for all non-Claude providers#50

Merged
Vanszs merged 0 commit into
Vanszs:mainfrom
mahdiwafy:fix/claude-format-response
Jul 14, 2026
Merged

fix(v1/messages): reverse-translate OpenAI->Claude for all non-Claude providers#50
Vanszs merged 0 commit into
Vanszs:mainfrom
mahdiwafy:fix/claude-format-response

Conversation

@mahdiwafy

Copy link
Copy Markdown

Summary

Reverse-translate OpenAI chat.completion responses back to Claude message format when the client sent a Claude-format request through a non-Claude provider (Gemini, Antigravity, etc.).

Changes

nonStreamingHandler.js (+72/-68 = net +4):

  • Add openaiToClaudeNonStreaming() converter: maps OpenAI {choices, usage} → Claude {id, type, role, content, stop_reason, usage}
  • Widen reverse-translation gate: check sourceFormat === FORMATS.CLAUDE && responseBody?.choices instead of targetFormat === FORMATS.OPENAI && sourceFormat === FORMATS.CLAUDE. Catches combo routing where selected provider is Gemini/Antigravity (not just OpenAI), since translateNonStreamingResponse always converts to OpenAI shape first
  • Remove translateOpenAIToOpenAIResponses() dead code (4.8KB) — Responses API translation no longer happens in this path
  • Pass comboName through to saveUsageStats

sseToJsonHandler.js (+29/-5 = net +24):

  • Import openaiToClaudeNonStreaming from nonStreamingHandler
  • Add Claude format reverse translation in SSE→JSON Chat Completions path (force-stream providers that aggregate SSE to OpenAI JSON)

Testing

Deployed at port 20126 and tested with Claude Code (Send Message) through a Gemini combo — returns proper Claude message format instead of raw OpenAI chat.completion JSON.

@mahdiwafy mahdiwafy force-pushed the fix/claude-format-response branch from 10f3566 to 6079896 Compare July 13, 2026 13:38
@Vanszs Vanszs added help wanted Extra attention is needed translator translator related labels Jul 13, 2026
@Vanszs

Vanszs commented Jul 13, 2026

Copy link
Copy Markdown
Owner

lot of conflict, please resolve it first 🗿

@mahdiwafy mahdiwafy force-pushed the fix/claude-format-response branch from 6079896 to 10f3566 Compare July 13, 2026 23:12
@mahdiwafy

mahdiwafy commented Jul 13, 2026

Copy link
Copy Markdown
Author

@Vanszs PR is clean and ready for review.

Merge check

  • mergeable: ✅ MERGEABLE
  • mergeStateStatus: ✅ CLEAN
  • Base: main (up-to-date, 0 commits behind)
  • Changed files: 2 files (+176/-126)
  • Dry-run merge: Automatic merge went well — zero conflict

What this does

Reverse-translates OpenAI-format responses to Claude message format when the client sends Claude-format requests (/v1/messages). This allows Claude Code (and any Anthropic-format client) to work through VansRouter with any provider.

Both the standard non-streaming path and the SSE-to-JSON (force non-streaming) path are covered.

Vanszs added a commit that referenced this pull request Jul 14, 2026
…ponse reverse-translation with tool decloaking
@Vanszs Vanszs merged commit a138ec6 into Vanszs:main Jul 14, 2026
12 checks passed
@Vanszs

Vanszs commented Jul 14, 2026

Copy link
Copy Markdown
Owner

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed translator translator related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants