Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b6350ce
feat: add Codex channel disclaimer (i18n, OpenAI terms)
seefs001 Feb 5, 2026
b5b6813
fix: restore log content column
seefs001 Feb 5, 2026
fca80a5
fix: Claude stream block index/type transitions
seefs001 Feb 5, 2026
7314c97
fix: Claude stream block index/type transitions
seefs001 Feb 5, 2026
2567cff
fix(oauth): enhance error handling and transaction management for OAu…
Calcium-Ion Feb 5, 2026
e8d26e5
refactor(oauth): update UpdateCustomOAuthProviderRequest to use point…
Calcium-Ion Feb 5, 2026
2504818
feat: add claude-opus-4-6
prnake Feb 6, 2026
ff71786
fix: aws claude
prnake Feb 6, 2026
c9f5de7
feat: support adaptive thinking
prnake Feb 6, 2026
729610b
fix: set temperature to 1
prnake Feb 6, 2026
8e6071f
Merge branch 'feat/claude-opus-4-6' of https://github.com/prnake/new-…
prnake Feb 6, 2026
b580b8b
fix: add paragraph breaks between reasoning summary chunks in chat2re…
seefs001 Feb 6, 2026
a1695b7
feat: gpt-5.3-codex
seefs001 Feb 6, 2026
ab5456e
🔒 fix(security): sanitize AI-generated HTML to prevent XSS in playground
t0ng7u Feb 6, 2026
aa8240e
feat: /v1/messages -> /v1/responses
seefs001 Feb 6, 2026
3af53bd
fix max_output_token
seefs001 Feb 6, 2026
6de8dea
Merge commit from fork
Calcium-Ion Feb 6, 2026
f3d6e99
Merge pull request #2863 from prnake/feat/claude-opus-4-6
Calcium-Ion Feb 6, 2026
3e1be18
fix: harden token search with pagination, rate limiting and input val…
Calcium-Ion Feb 6, 2026
053699f
Merge commit from fork
Calcium-Ion Feb 6, 2026
5ff9bc3
chore: add fmt import for improved logging in token controller
Calcium-Ion Feb 6, 2026
04dd761
fix: update LIKE pattern sanitization for token search
Calcium-Ion Feb 6, 2026
8ec16fa
feat(topup): hide subscription plans card when no plans available
QuentinHsu Feb 6, 2026
4332837
feat: Force beta=true parameter for Anthropic channel
MUTED64 Feb 6, 2026
d814d62
refactor: enhance API security with read-only token authentication an…
Calcium-Ion Feb 6, 2026
57059ac
fix: /v1/chat/completions -> /v1/responses json_schema
seefs001 Feb 6, 2026
f18aec5
Merge pull request #2876 from seefs001/fix/json_schema
Calcium-Ion Feb 6, 2026
0c0ccf5
refactor: 抽象统一计费会话 BillingSession
Calcium-Ion Feb 6, 2026
15fc77d
fix: 修复 BillingSession 多个边界问题
Calcium-Ion Feb 6, 2026
158baf0
✨ refactor(wallet): Top-up layout to embed subscription plans into th…
t0ng7u Feb 6, 2026
e57bac7
Merge pull request #2878 from QuantumNous/feat/hide-subscription-card…
Calcium-Ion Feb 6, 2026
8b8ea60
Merge pull request #2877 from QuantumNous/refactor/billing-session
Calcium-Ion Feb 6, 2026
1cc6bf1
✨ chore: Improve subscription billing fallback and UI states
t0ng7u Feb 6, 2026
10c5f5f
🛠️ fix: billing session error handling for subscription-first fallback.
t0ng7u Feb 6, 2026
82138fc
🔔 feat: Add subscription-aware quota notifications and update UI copy
t0ng7u Feb 6, 2026
60d4750
Merge pull request #2880 from QuantumNous/feat/subscription-quota-notify
Calcium-Ion Feb 7, 2026
aa31b9c
Merge pull request #2879 from QuantumNous/fix/subscription-preference…
Calcium-Ion Feb 7, 2026
c8aee5e
🔧 refactor: Update formatUserLogs function to accept start index
Calcium-Ion Feb 7, 2026
0837090
🔧 refactor: Enhance Log struct indexing for improved query performance
Calcium-Ion Feb 7, 2026
22d7fdb
codex tips
seefs001 Feb 7, 2026
78ddb85
Merge pull request #2852 from seefs001/fix/codex-tips
Calcium-Ion Feb 7, 2026
5f6f95c
Merge pull request #2874 from MUTED64/main
seefs001 Feb 7, 2026
8e1a990
Merge pull request #2857 from QuantumNous/feat/custom-oauth
Calcium-Ion Feb 7, 2026
dd5610d
Merge pull request #2854 from seefs001/fix/claude-tool-index
Calcium-Ion Feb 7, 2026
ce0113a
Merge pull request #2864 from seefs001/fix/thining-summary
Calcium-Ion Feb 7, 2026
2faa873
Merge branch 'feature/messages2responses' into upstream-main
seefs001 Feb 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion relay/channel/openai/adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
url = strings.Replace(url, "{model}", info.UpstreamModelName, -1)
return url, nil
default:
if info.RelayFormat == types.RelayFormatClaude || info.RelayFormat == types.RelayFormatGemini {
if (info.RelayFormat == types.RelayFormatClaude || info.RelayFormat == types.RelayFormatGemini) &&
info.RelayMode != relayconstant.RelayModeResponses &&
info.RelayMode != relayconstant.RelayModeResponsesCompact {
return fmt.Sprintf("%s/v1/chat/completions", info.ChannelBaseUrl), nil
}
return relaycommon.GetFullRequestURL(info.ChannelBaseUrl, info.RequestURLPath, info.ChannelType), nil
Expand Down
77 changes: 59 additions & 18 deletions relay/channel/openai/chat_via_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,22 @@ func OaiResponsesToChatHandler(c *gin.Context, info *relaycommon.RelayInfo, resp
chatResp.Usage = *usage
}

chatBody, err := common.Marshal(chatResp)
var responseBody []byte
switch info.RelayFormat {
case types.RelayFormatClaude:
claudeResp := service.ResponseOpenAI2Claude(chatResp, info)
responseBody, err = common.Marshal(claudeResp)
case types.RelayFormatGemini:
geminiResp := service.ResponseOpenAI2Gemini(chatResp, info)
responseBody, err = common.Marshal(geminiResp)
default:
responseBody, err = common.Marshal(chatResp)
}
if err != nil {
return nil, types.NewOpenAIError(err, types.ErrorCodeJsonMarshalFailed, http.StatusInternalServerError)
}

service.IOCopyBytesGracefully(c, resp, chatBody)
service.IOCopyBytesGracefully(c, resp, responseBody)
return usage, nil
}

Expand Down Expand Up @@ -108,12 +118,39 @@ func OaiResponsesToChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo
toolCallCanonicalIDByItemID := make(map[string]string)
//reasoningSummaryTextByKey := make(map[string]string)

if info.RelayFormat == types.RelayFormatClaude && info.ClaudeConvertInfo == nil {
info.ClaudeConvertInfo = &relaycommon.ClaudeConvertInfo{LastMessagesType: relaycommon.LastMessageTypeNone}
}

sendChatChunk := func(chunk *dto.ChatCompletionsStreamResponse) bool {
if chunk == nil {
return true
}
if info.RelayFormat == types.RelayFormatOpenAI {
if err := helper.ObjectData(c, chunk); err != nil {
streamErr = types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
return false
}
return true
}

chunkData, err := common.Marshal(chunk)
if err != nil {
streamErr = types.NewOpenAIError(err, types.ErrorCodeJsonMarshalFailed, http.StatusInternalServerError)
return false
}
if err := HandleStreamFormat(c, info, string(chunkData), false, false); err != nil {
streamErr = types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
return false
}
return true
}

sendStartIfNeeded := func() bool {
if sentStart {
return true
}
if err := helper.ObjectData(c, helper.GenerateStartEmptyResponse(responseId, createAt, model, nil)); err != nil {
streamErr = types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
if !sendChatChunk(helper.GenerateStartEmptyResponse(responseId, createAt, model, nil)) {
return false
}
sentStart = true
Expand Down Expand Up @@ -173,8 +210,7 @@ func OaiResponsesToChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo
},
},
}
if err := helper.ObjectData(c, chunk); err != nil {
streamErr = types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
if !sendChatChunk(chunk) {
return false
}
return true
Expand Down Expand Up @@ -231,8 +267,7 @@ func OaiResponsesToChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo
},
},
}
if err := helper.ObjectData(c, chunk); err != nil {
streamErr = types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
if !sendChatChunk(chunk) {
return false
}
sawToolCall = true
Expand Down Expand Up @@ -323,8 +358,7 @@ func OaiResponsesToChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo
},
},
}
if err := helper.ObjectData(c, chunk); err != nil {
streamErr = types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
if !sendChatChunk(chunk) {
return false
}
}
Expand Down Expand Up @@ -419,13 +453,15 @@ func OaiResponsesToChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo
return false
}
if !sentStop {
if info.RelayFormat == types.RelayFormatClaude && info.ClaudeConvertInfo != nil {
info.ClaudeConvertInfo.Usage = usage
}
finishReason := "stop"
if sawToolCall && outputText.Len() == 0 {
finishReason = "tool_calls"
}
stop := helper.GenerateStopResponse(responseId, createAt, model, finishReason)
if err := helper.ObjectData(c, stop); err != nil {
streamErr = types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
if !sendChatChunk(stop) {
return false
}
sentStop = true
Expand Down Expand Up @@ -456,26 +492,31 @@ func OaiResponsesToChatStreamHandler(c *gin.Context, info *relaycommon.RelayInfo
}

if !sentStart {
if err := helper.ObjectData(c, helper.GenerateStartEmptyResponse(responseId, createAt, model, nil)); err != nil {
return nil, types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
if !sendChatChunk(helper.GenerateStartEmptyResponse(responseId, createAt, model, nil)) {
return nil, streamErr
}
}
if !sentStop {
if info.RelayFormat == types.RelayFormatClaude && info.ClaudeConvertInfo != nil {
info.ClaudeConvertInfo.Usage = usage
}
finishReason := "stop"
if sawToolCall && outputText.Len() == 0 {
finishReason = "tool_calls"
}
stop := helper.GenerateStopResponse(responseId, createAt, model, finishReason)
if err := helper.ObjectData(c, stop); err != nil {
return nil, types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
if !sendChatChunk(stop) {
return nil, streamErr
}
}
if info.ShouldIncludeUsage && usage != nil {
if info.RelayFormat == types.RelayFormatOpenAI && info.ShouldIncludeUsage && usage != nil {
if err := helper.ObjectData(c, helper.GenerateFinalUsageResponse(responseId, createAt, model, *usage)); err != nil {
return nil, types.NewOpenAIError(err, types.ErrorCodeBadResponse, http.StatusInternalServerError)
}
}

helper.Done(c)
if info.RelayFormat == types.RelayFormatOpenAI {
helper.Done(c)
}
return usage, nil
}
17 changes: 17 additions & 0 deletions relay/claude_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,23 @@ func ClaudeHelper(c *gin.Context, info *relaycommon.RelayInfo) (newAPIError *typ
}
}

if !model_setting.GetGlobalSettings().PassThroughRequestEnabled &&
!info.ChannelSetting.PassThroughBodyEnabled &&
service.ShouldChatCompletionsUseResponsesGlobal(info.ChannelId, info.ChannelType, info.OriginModelName) {
openAIRequest, convErr := service.ClaudeToOpenAIRequest(*request, info)
if convErr != nil {
return types.NewError(convErr, types.ErrorCodeConvertRequestFailed, types.ErrOptionWithSkipRetry())
}

usage, newApiErr := chatCompletionsViaResponses(c, info, adaptor, openAIRequest)
if newApiErr != nil {
return newApiErr
}

service.PostClaudeConsumeQuota(c, info, usage)
return nil
}

var requestBody io.Reader
if model_setting.GetGlobalSettings().PassThroughRequestEnabled || info.ChannelSetting.PassThroughBodyEnabled {
body, err := common.GetRequestBody(c)
Expand Down
4 changes: 4 additions & 0 deletions service/openaicompat/chat_to_responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ func ChatCompletionsRequestToResponsesRequest(req *dto.GeneralOpenAIRequest) (*d
if req.MaxCompletionTokens > maxOutputTokens {
maxOutputTokens = req.MaxCompletionTokens
}
// OpenAI Responses API rejects max_output_tokens < 16 when explicitly provided.
if maxOutputTokens > 0 && maxOutputTokens < 16 {
maxOutputTokens = 16
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

var topP *float64
if req.TopP != 0 {
Expand Down