From 05c73c6fc37007cacaf4ee4da011936379fe656e Mon Sep 17 00:00:00 2001 From: "Laisky.Cai" Date: Wed, 27 Nov 2024 06:00:17 +0000 Subject: [PATCH] feat: add new models and update pricing for o1-preview and o1-mini in constants and ratios --- relay/adaptor/openai/constants.go | 5 ++--- relay/billing/ratio/model.go | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/relay/adaptor/openai/constants.go b/relay/adaptor/openai/constants.go index aacdba1a..ebb2258b 100644 --- a/relay/adaptor/openai/constants.go +++ b/relay/adaptor/openai/constants.go @@ -7,9 +7,7 @@ var ModelList = []string{ "gpt-4", "gpt-4-0314", "gpt-4-0613", "gpt-4-1106-preview", "gpt-4-0125-preview", "gpt-4-32k", "gpt-4-32k-0314", "gpt-4-32k-0613", "gpt-4-turbo-preview", "gpt-4-turbo", "gpt-4-turbo-2024-04-09", - "gpt-4o", "gpt-4o-2024-05-13", - "gpt-4o-2024-08-06", - "chatgpt-4o-latest", + "gpt-4o", "gpt-4o-2024-05-13", "gpt-4o-2024-08-06", "gpt-4o-2024-11-20", "chatgpt-4o-latest", "gpt-4o-mini", "gpt-4o-mini-2024-07-18", "gpt-4-vision-preview", "text-embedding-ada-002", "text-embedding-3-small", "text-embedding-3-large", @@ -20,4 +18,5 @@ var ModelList = []string{ "dall-e-2", "dall-e-3", "whisper-1", "tts-1", "tts-1-1106", "tts-1-hd", "tts-1-hd-1106", + "o1-preview", "o1-preview-2024-09-12", } diff --git a/relay/billing/ratio/model.go b/relay/billing/ratio/model.go index b8f140a1..e9aec52c 100644 --- a/relay/billing/ratio/model.go +++ b/relay/billing/ratio/model.go @@ -37,6 +37,7 @@ var ModelRatio = map[string]float64{ "chatgpt-4o-latest": 2.5, // $0.005 / 1K tokens "gpt-4o-2024-05-13": 2.5, // $0.005 / 1K tokens "gpt-4o-2024-08-06": 1.25, // $0.0025 / 1K tokens + "gpt-4o-2024-11-20": 1.25, // $0.0025 / 1K tokens "gpt-4o-mini": 0.075, // $0.00015 / 1K tokens "gpt-4o-mini-2024-07-18": 0.075, // $0.00015 / 1K tokens "gpt-4-vision-preview": 5, // $0.01 / 1K tokens @@ -48,8 +49,12 @@ var ModelRatio = map[string]float64{ "gpt-3.5-turbo-instruct": 0.75, // $0.0015 / 1K tokens "gpt-3.5-turbo-1106": 0.5, // $0.001 / 1K tokens "gpt-3.5-turbo-0125": 0.25, // $0.0005 / 1K tokens - "davinci-002": 1, // $0.002 / 1K tokens - "babbage-002": 0.2, // $0.0004 / 1K tokens + "o1-preview": 7.5, // $15.00 / 1M input tokens + "o1-preview-2024-09-12": 7.5, + "o1-mini": 1.5, // $3.00 / 1M input tokens + "o1-mini-2024-09-12": 1.5, + "davinci-002": 1, // $0.002 / 1K tokens + "babbage-002": 0.2, // $0.0004 / 1K tokens "text-ada-001": 0.2, "text-babbage-001": 0.25, "text-curie-001": 1, @@ -345,6 +350,12 @@ func GetCompletionRatio(name string, channelType int) float64 { } return 2 } + if strings.HasPrefix(name, "o1-preview") { + return 4 + } + if strings.HasPrefix(name, "o1-mini") { + return 4 + } if name == "chatgpt-4o-latest" { return 3 }