From 8b5c6feb5e138a4ef6b7745300d99c73c50c2c1e Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Wed, 1 Jan 2025 23:12:05 +0800 Subject: [PATCH 1/2] add azure o1 --- store/cache.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/store/cache.go b/store/cache.go index 37aab6c..5f8376b 100644 --- a/store/cache.go +++ b/store/cache.go @@ -82,7 +82,7 @@ func SelectKeyCacheByModel(model string) (Key, error) { } items := KeysCache.Items() for _, item := range items { - if strings.Contains(model, "realtime") { + if strings.Contains(model, "realtime") || strings.HasPrefix(model, "o1-") { if item.Object.(Key).ApiType == "openai" { keys = append(keys, item.Object.(Key)) } @@ -101,7 +101,7 @@ func SelectKeyCacheByModel(model string) (Key, error) { keys = append(keys, item.Object.(Key)) } } - if strings.HasPrefix(model, "o1-") || strings.HasPrefix(model, "chatgpt-") { + if strings.HasPrefix(model, "chatgpt-") { if item.Object.(Key).ApiType == "openai" { keys = append(keys, item.Object.(Key)) } From 1e00905dcb4d06e17273f76f12861af768d9c459 Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Sun, 2 Feb 2025 00:31:46 +0800 Subject: [PATCH 2/2] o3 --- pkg/tokenizer/tokenizer.go | 20 +++++++++++++++----- router/chat.go | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pkg/tokenizer/tokenizer.go b/pkg/tokenizer/tokenizer.go index 9579948..40224f9 100644 --- a/pkg/tokenizer/tokenizer.go +++ b/pkg/tokenizer/tokenizer.go @@ -109,14 +109,24 @@ func Cost(model string, promptCount, completionCount int) float64 { cost = 0.015*float64(prompt/1000) + 0.06*float64(completion/1000) case "o1-mini", "o1-mini-2024-09-12": cost = 0.003*float64(prompt/1000) + 0.012*float64(completion/1000) - // Realtime API - // Audio* - // $0.1 / 1K input tokens - // $0.2 / 1K output tokens + case "o3-mini", "o3-mini-2025-01-31": + cost = 0.003*float64(prompt/1000) + 0.012*float64(completion/1000) + // Realtime API + // Audio* + // $0.1 / 1K input tokens + // $0.2 / 1K output tokens + case "gpt-4o-audio-preview", "gpt-4o-audio-preview-2024-12-17": + cost = 0.0025*float64(prompt/1000) + 0.01*float64(completion/1000) case "gpt-4o-realtime-preview", "gpt-4o-realtime-preview-2024-10-01": cost = 0.005*float64(prompt/1000) + 0.020*float64(completion/1000) case "gpt-4o-realtime-preview.audio", "gpt-4o-realtime-preview-2024-10-01.audio": cost = 0.1*float64(prompt/1000) + 0.2*float64(completion/1000) + + case "gpt-4o-mini-audio-preview", "gpt-4o-mini-audio-preview-2024-12-17": + cost = 0.00015*float64(prompt/1000) + 0.0006*float64(completion/1000) + case "gpt-4o-mini-realtime-preview", "gpt-4o-mini-realtime-preview-2024-12-17": + cost = 0.0006*float64(prompt/1000) + 0.0024*float64(completion/1000) + case "whisper-1": // 0.006$/min cost = 0.006 * float64(prompt+completion) / 60 @@ -183,7 +193,7 @@ func Cost(model string, promptCount, completionCount int) float64 { cost = (0.00035/1000)*float64(prompt) + (0.00053/1000)*float64(completion) case "gemini-2.0-flash-exp": cost = (0.00035/1000)*float64(prompt) + (0.00053/1000)*float64(completion) - case "gemini-2.0-flash-thinking-exp-1219": + case "gemini-2.0-flash-thinking-exp-1219", "gemini-2.0-flash-thinking-exp-01-21": cost = (0.00035/1000)*float64(prompt) + (0.00053/1000)*float64(completion) case "learnlm-1.5-pro-experimental", " gemini-exp-1114", "gemini-exp-1121", "gemini-exp-1206": cost = (0.00035/1000)*float64(prompt) + (0.00053/1000)*float64(completion) diff --git a/router/chat.go b/router/chat.go index 0637192..0fec502 100644 --- a/router/chat.go +++ b/router/chat.go @@ -18,7 +18,7 @@ func ChatHandler(c *gin.Context) { return } - if strings.Contains(chatreq.Model, "gpt") || strings.HasPrefix(chatreq.Model, "o1-") { + if strings.Contains(chatreq.Model, "gpt") || strings.HasPrefix(chatreq.Model, "o1") || strings.HasPrefix(chatreq.Model, "o3") { openai.ChatProxy(c, &chatreq) return }