From 012d6018f47b30bdffe691b6f1058bb8bca594ab Mon Sep 17 00:00:00 2001 From: longkeyy Date: Sat, 1 Mar 2025 14:33:34 +0800 Subject: [PATCH] feat: add support gpt-4.5-preview --- relay/adaptor/openai/constants.go | 2 + relay/adaptor/openrouter/constants.go | 209 +++++++++++++------------- relay/billing/ratio/model.go | 128 ++++++++-------- 3 files changed, 174 insertions(+), 165 deletions(-) diff --git a/relay/adaptor/openai/constants.go b/relay/adaptor/openai/constants.go index 8a643bc6..e444b1bc 100644 --- a/relay/adaptor/openai/constants.go +++ b/relay/adaptor/openai/constants.go @@ -24,4 +24,6 @@ var ModelList = []string{ "o1", "o1-2024-12-17", "o1-preview", "o1-preview-2024-09-12", "o1-mini", "o1-mini-2024-09-12", + "o3-mini", "o3-mini-2025-01-31", + "gpt-4.5-preview", "gpt-4.5-preview-2025-02-27", } diff --git a/relay/adaptor/openrouter/constants.go b/relay/adaptor/openrouter/constants.go index b12fa65c..e908b3fe 100644 --- a/relay/adaptor/openrouter/constants.go +++ b/relay/adaptor/openrouter/constants.go @@ -1,20 +1,35 @@ package openrouter var ModelList = []string{ - "01-ai/yi-large", - "aetherwiing/mn-starcannon-12b", - "ai21/jamba-1-5-large", - "ai21/jamba-1-5-mini", - "ai21/jamba-instruct", - "aion-labs/aion-1.0", - "aion-labs/aion-1.0-mini", - "aion-labs/aion-rp-llama-3.1-8b", - "allenai/llama-3.1-tulu-3-405b", - "alpindale/goliath-120b", - "alpindale/magnum-72b", - "amazon/nova-lite-v1", - "amazon/nova-micro-v1", - "amazon/nova-pro-v1", + "chatgpt-4o-latest", + "gpt-3.5-turbo", + "gpt-3.5-turbo-0125", + "gpt-3.5-turbo-0613", + "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-16k", + "gpt-3.5-turbo-instruct", + "gpt-4", + "gpt-4-0314", + "gpt-4-1106-preview", + "gpt-4-32k", + "gpt-4-32k-0314", + "gpt-4-turbo", + "gpt-4-turbo-preview", + "gpt-4o", + "gpt-4o-2024-05-13", + "gpt-4o-2024-08-06", + "gpt-4o-2024-11-20", + "gpt-4o-mini", + "gpt-4o-mini-2024-07-18", + "gpt-4o:extended", + "o1", + "o1-mini", + "o1-mini-2024-09-12", + "o1-preview", + "o1-preview-2024-09-12", + "o3-mini", + "o3-mini-high", + "gpt-4.5-preview", "anthracite-org/magnum-v2-72b", "anthracite-org/magnum-v4-72b", "anthropic/claude-2", @@ -37,31 +52,6 @@ var ModelList = []string{ "anthropic/claude-3.5-sonnet-20240620", "anthropic/claude-3.5-sonnet-20240620:beta", "anthropic/claude-3.5-sonnet:beta", - "cognitivecomputations/dolphin-mixtral-8x22b", - "cognitivecomputations/dolphin-mixtral-8x7b", - "cohere/command", - "cohere/command-r", - "cohere/command-r-03-2024", - "cohere/command-r-08-2024", - "cohere/command-r-plus", - "cohere/command-r-plus-04-2024", - "cohere/command-r-plus-08-2024", - "cohere/command-r7b-12-2024", - "databricks/dbrx-instruct", - "deepseek/deepseek-chat", - "deepseek/deepseek-chat-v2.5", - "deepseek/deepseek-chat:free", - "deepseek/deepseek-r1", - "deepseek/deepseek-r1-distill-llama-70b", - "deepseek/deepseek-r1-distill-llama-70b:free", - "deepseek/deepseek-r1-distill-llama-8b", - "deepseek/deepseek-r1-distill-qwen-1.5b", - "deepseek/deepseek-r1-distill-qwen-14b", - "deepseek/deepseek-r1-distill-qwen-32b", - "deepseek/deepseek-r1:free", - "eva-unit-01/eva-llama-3.33-70b", - "eva-unit-01/eva-qwen-2.5-32b", - "eva-unit-01/eva-qwen-2.5-72b", "google/gemini-2.0-flash-001", "google/gemini-2.0-flash-exp:free", "google/gemini-2.0-flash-lite-preview-02-05:free", @@ -84,17 +74,32 @@ var ModelList = []string{ "google/palm-2-chat-bison-32k", "google/palm-2-codechat-bison", "google/palm-2-codechat-bison-32k", - "gryphe/mythomax-l2-13b", - "gryphe/mythomax-l2-13b:free", - "huggingfaceh4/zephyr-7b-beta:free", - "infermatic/mn-inferor-12b", - "inflection/inflection-3-pi", - "inflection/inflection-3-productivity", - "jondurbin/airoboros-l2-70b", - "liquid/lfm-3b", - "liquid/lfm-40b", - "liquid/lfm-7b", - "mancer/weaver", + "deepseek/deepseek-chat", + "deepseek/deepseek-chat-v2.5", + "deepseek/deepseek-chat:free", + "deepseek/deepseek-r1", + "deepseek/deepseek-r1-distill-llama-70b", + "deepseek/deepseek-r1-distill-llama-70b:free", + "deepseek/deepseek-r1-distill-llama-8b", + "deepseek/deepseek-r1-distill-qwen-1.5b", + "deepseek/deepseek-r1-distill-qwen-14b", + "deepseek/deepseek-r1-distill-qwen-32b", + "deepseek/deepseek-r1:free", + "qwen/qvq-72b-preview", + "qwen/qwen-2-72b-instruct", + "qwen/qwen-2-7b-instruct", + "qwen/qwen-2-7b-instruct:free", + "qwen/qwen-2-vl-72b-instruct", + "qwen/qwen-2-vl-7b-instruct", + "qwen/qwen-2.5-72b-instruct", + "qwen/qwen-2.5-7b-instruct", + "qwen/qwen-2.5-coder-32b-instruct", + "qwen/qwen-max", + "qwen/qwen-plus", + "qwen/qwen-turbo", + "qwen/qwen-vl-plus:free", + "qwen/qwen2.5-vl-72b-instruct:free", + "qwen/qwq-32b-preview", "meta-llama/llama-2-13b-chat", "meta-llama/llama-2-70b-chat", "meta-llama/llama-3-70b-instruct", @@ -112,6 +117,10 @@ var ModelList = []string{ "meta-llama/llama-3.3-70b-instruct", "meta-llama/llama-3.3-70b-instruct:free", "meta-llama/llama-guard-2-8b", + "x-ai/grok-2-1212", + "x-ai/grok-2-vision-1212", + "x-ai/grok-beta", + "x-ai/grok-vision-beta", "microsoft/phi-3-medium-128k-instruct", "microsoft/phi-3-medium-128k-instruct:free", "microsoft/phi-3-mini-128k-instruct", @@ -144,6 +153,52 @@ var ModelList = []string{ "mistralai/mixtral-8x7b-instruct", "mistralai/pixtral-12b", "mistralai/pixtral-large-2411", + "perplexity/llama-3.1-sonar-huge-128k-online", + "perplexity/llama-3.1-sonar-large-128k-chat", + "perplexity/llama-3.1-sonar-large-128k-online", + "perplexity/llama-3.1-sonar-small-128k-chat", + "perplexity/llama-3.1-sonar-small-128k-online", + "perplexity/sonar", + "perplexity/sonar-reasoning", + "01-ai/yi-large", + "aetherwiing/mn-starcannon-12b", + "ai21/jamba-1-5-large", + "ai21/jamba-1-5-mini", + "ai21/jamba-instruct", + "aion-labs/aion-1.0", + "aion-labs/aion-1.0-mini", + "aion-labs/aion-rp-llama-3.1-8b", + "allenai/llama-3.1-tulu-3-405b", + "alpindale/goliath-120b", + "alpindale/magnum-72b", + "amazon/nova-lite-v1", + "amazon/nova-micro-v1", + "amazon/nova-pro-v1", + "cognitivecomputations/dolphin-mixtral-8x22b", + "cognitivecomputations/dolphin-mixtral-8x7b", + "cohere/command", + "cohere/command-r", + "cohere/command-r-03-2024", + "cohere/command-r-08-2024", + "cohere/command-r-plus", + "cohere/command-r-plus-04-2024", + "cohere/command-r-plus-08-2024", + "cohere/command-r7b-12-2024", + "databricks/dbrx-instruct", + "eva-unit-01/eva-llama-3.33-70b", + "eva-unit-01/eva-qwen-2.5-32b", + "eva-unit-01/eva-qwen-2.5-72b", + "gryphe/mythomax-l2-13b", + "gryphe/mythomax-l2-13b:free", + "huggingfaceh4/zephyr-7b-beta:free", + "infermatic/mn-inferor-12b", + "inflection/inflection-3-pi", + "inflection/inflection-3-productivity", + "jondurbin/airoboros-l2-70b", + "liquid/lfm-3b", + "liquid/lfm-40b", + "liquid/lfm-7b", + "mancer/weaver", "neversleep/llama-3-lumimaid-70b", "neversleep/llama-3-lumimaid-8b", "neversleep/llama-3-lumimaid-8b:extended", @@ -158,60 +213,10 @@ var ModelList = []string{ "nousresearch/nous-hermes-llama2-13b", "nvidia/llama-3.1-nemotron-70b-instruct", "nvidia/llama-3.1-nemotron-70b-instruct:free", - "openai/chatgpt-4o-latest", - "openai/gpt-3.5-turbo", - "openai/gpt-3.5-turbo-0125", - "openai/gpt-3.5-turbo-0613", - "openai/gpt-3.5-turbo-1106", - "openai/gpt-3.5-turbo-16k", - "openai/gpt-3.5-turbo-instruct", - "openai/gpt-4", - "openai/gpt-4-0314", - "openai/gpt-4-1106-preview", - "openai/gpt-4-32k", - "openai/gpt-4-32k-0314", - "openai/gpt-4-turbo", - "openai/gpt-4-turbo-preview", - "openai/gpt-4o", - "openai/gpt-4o-2024-05-13", - "openai/gpt-4o-2024-08-06", - "openai/gpt-4o-2024-11-20", - "openai/gpt-4o-mini", - "openai/gpt-4o-mini-2024-07-18", - "openai/gpt-4o:extended", - "openai/o1", - "openai/o1-mini", - "openai/o1-mini-2024-09-12", - "openai/o1-preview", - "openai/o1-preview-2024-09-12", - "openai/o3-mini", - "openai/o3-mini-high", "openchat/openchat-7b", "openchat/openchat-7b:free", "openrouter/auto", - "perplexity/llama-3.1-sonar-huge-128k-online", - "perplexity/llama-3.1-sonar-large-128k-chat", - "perplexity/llama-3.1-sonar-large-128k-online", - "perplexity/llama-3.1-sonar-small-128k-chat", - "perplexity/llama-3.1-sonar-small-128k-online", - "perplexity/sonar", - "perplexity/sonar-reasoning", "pygmalionai/mythalion-13b", - "qwen/qvq-72b-preview", - "qwen/qwen-2-72b-instruct", - "qwen/qwen-2-7b-instruct", - "qwen/qwen-2-7b-instruct:free", - "qwen/qwen-2-vl-72b-instruct", - "qwen/qwen-2-vl-7b-instruct", - "qwen/qwen-2.5-72b-instruct", - "qwen/qwen-2.5-7b-instruct", - "qwen/qwen-2.5-coder-32b-instruct", - "qwen/qwen-max", - "qwen/qwen-plus", - "qwen/qwen-turbo", - "qwen/qwen-vl-plus:free", - "qwen/qwen2.5-vl-72b-instruct:free", - "qwen/qwq-32b-preview", "raifle/sorcererlm-8x22b", "sao10k/fimbulvetr-11b-v2", "sao10k/l3-euryale-70b", @@ -227,9 +232,5 @@ var ModelList = []string{ "undi95/remm-slerp-l2-13b", "undi95/toppy-m-7b", "undi95/toppy-m-7b:free", - "x-ai/grok-2-1212", - "x-ai/grok-2-vision-1212", - "x-ai/grok-beta", - "x-ai/grok-vision-beta", "xwin-lm/xwin-lm-70b", } diff --git a/relay/billing/ratio/model.go b/relay/billing/ratio/model.go index e8b3b615..15d61a88 100644 --- a/relay/billing/ratio/model.go +++ b/relay/billing/ratio/model.go @@ -26,67 +26,69 @@ var modelRatioLock sync.RWMutex // 1 === ¥0.014 / 1k tokens var ModelRatio = map[string]float64{ // https://openai.com/pricing - "gpt-4": 15, - "gpt-4-0314": 15, - "gpt-4-0613": 15, - "gpt-4-32k": 30, - "gpt-4-32k-0314": 30, - "gpt-4-32k-0613": 30, - "gpt-4-1106-preview": 5, // $0.01 / 1K tokens - "gpt-4-0125-preview": 5, // $0.01 / 1K tokens - "gpt-4-turbo-preview": 5, // $0.01 / 1K tokens - "gpt-4-turbo": 5, // $0.01 / 1K tokens - "gpt-4-turbo-2024-04-09": 5, // $0.01 / 1K tokens - "gpt-4o": 2.5, // $0.005 / 1K tokens - "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 - "gpt-3.5-turbo": 0.25, // $0.0005 / 1K tokens - "gpt-3.5-turbo-0301": 0.75, - "gpt-3.5-turbo-0613": 0.75, - "gpt-3.5-turbo-16k": 1.5, // $0.003 / 1K tokens - "gpt-3.5-turbo-16k-0613": 1.5, - "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 - "o1": 7.5, // $15.00 / 1M input tokens - "o1-2024-12-17": 7.5, - "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, - "o3-mini": 1.5, // $3.00 / 1M input tokens - "o3-mini-2025-01-31": 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, - "text-davinci-002": 10, - "text-davinci-003": 10, - "text-davinci-edit-001": 10, - "code-davinci-edit-001": 10, - "whisper-1": 15, // $0.006 / minute -> $0.006 / 150 words -> $0.006 / 200 tokens -> $0.03 / 1k tokens - "tts-1": 7.5, // $0.015 / 1K characters - "tts-1-1106": 7.5, - "tts-1-hd": 15, // $0.030 / 1K characters - "tts-1-hd-1106": 15, - "davinci": 10, - "curie": 10, - "babbage": 10, - "ada": 10, - "text-embedding-ada-002": 0.05, - "text-embedding-3-small": 0.01, - "text-embedding-3-large": 0.065, - "text-search-ada-doc-001": 10, - "text-moderation-stable": 0.1, - "text-moderation-latest": 0.1, - "dall-e-2": 0.02 * USD, // $0.016 - $0.020 / image - "dall-e-3": 0.04 * USD, // $0.040 - $0.120 / image + "gpt-4": 15, + "gpt-4-0314": 15, + "gpt-4-0613": 15, + "gpt-4-32k": 30, + "gpt-4-32k-0314": 30, + "gpt-4-32k-0613": 30, + "gpt-4-1106-preview": 5, // $0.01 / 1K tokens + "gpt-4-0125-preview": 5, // $0.01 / 1K tokens + "gpt-4-turbo-preview": 5, // $0.01 / 1K tokens + "gpt-4-turbo": 5, // $0.01 / 1K tokens + "gpt-4-turbo-2024-04-09": 5, // $0.01 / 1K tokens + "gpt-4o": 2.5, // $0.005 / 1K tokens + "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 + "gpt-3.5-turbo": 0.25, // $0.0005 / 1K tokens + "gpt-3.5-turbo-0301": 0.75, + "gpt-3.5-turbo-0613": 0.75, + "gpt-3.5-turbo-16k": 1.5, // $0.003 / 1K tokens + "gpt-3.5-turbo-16k-0613": 1.5, + "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 + "o1": 7.5, // $15.00 / 1M input tokens + "o1-2024-12-17": 7.5, + "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, + "o3-mini": 1.5, // $3.00 / 1M input tokens + "o3-mini-2025-01-31": 1.5, + "gpt-4.5-preview": 37.5, + "gpt-4.5-preview-2025-02-27": 37.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, + "text-davinci-002": 10, + "text-davinci-003": 10, + "text-davinci-edit-001": 10, + "code-davinci-edit-001": 10, + "whisper-1": 15, // $0.006 / minute -> $0.006 / 150 words -> $0.006 / 200 tokens -> $0.03 / 1k tokens + "tts-1": 7.5, // $0.015 / 1K characters + "tts-1-1106": 7.5, + "tts-1-hd": 15, // $0.030 / 1K characters + "tts-1-hd-1106": 15, + "davinci": 10, + "curie": 10, + "babbage": 10, + "ada": 10, + "text-embedding-ada-002": 0.05, + "text-embedding-3-small": 0.01, + "text-embedding-3-large": 0.065, + "text-search-ada-doc-001": 10, + "text-moderation-stable": 0.1, + "text-moderation-latest": 0.1, + "dall-e-2": 0.02 * USD, // $0.016 - $0.020 / image + "dall-e-3": 0.04 * USD, // $0.040 - $0.120 / image // https://docs.anthropic.com/en/docs/about-claude/models "claude-instant-1.2": 0.8 / 1000 * USD, "claude-2.0": 8.0 / 1000 * USD, @@ -750,7 +752,11 @@ func GetCompletionRatio(name string, channelType int) float64 { } return 4.0 / 3.0 } + // including gpt-4, gpt-4.5 if strings.HasPrefix(name, "gpt-4") { + if strings.HasPrefix(name, "gpt-4.5") { + return 2 + } if strings.HasPrefix(name, "gpt-4o") { if name == "gpt-4o-2024-05-13" { return 3