diff --git a/relay/adaptor/openai/adaptor.go b/relay/adaptor/openai/adaptor.go index 6946e402..ede9fc13 100644 --- a/relay/adaptor/openai/adaptor.go +++ b/relay/adaptor/openai/adaptor.go @@ -82,6 +82,21 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, relayMode int, request *model.G } request.StreamOptions.IncludeUsage = true } + + // o1/o1-mini/o1-preview do not support system prompt and max_tokens + if strings.HasPrefix(request.Model, "o1") { + request.MaxTokens = 0 + request.Messages = func(raw []model.Message) (filtered []model.Message) { + for i := range raw { + if raw[i].Role != "system" { + filtered = append(filtered, raw[i]) + } + } + + return + }(request.Messages) + } + return request, nil } diff --git a/relay/billing/ratio/model.go b/relay/billing/ratio/model.go index f83aa70c..e7c89ca7 100644 --- a/relay/billing/ratio/model.go +++ b/relay/billing/ratio/model.go @@ -466,7 +466,7 @@ func GetCompletionRatio(name string, channelType int) float64 { } return 2 } - // including o1, o1-preview, o1-mini + // including o1/o1-preview/o1-mini if strings.HasPrefix(name, "o1") { return 4 }