Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7a3de654
authored
Jul 22, 2025
by
creamlike1024
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ZhangYichi-ZYc-alpha' into alpha
parents
0e679d06
e7f5d021
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
37 deletions
+13
-37
setting/operation_setting/tools.go
+13
-37
No files found.
setting/operation_setting/tools.go
View file @
7a3de654
...
@@ -4,12 +4,8 @@ import "strings"
...
@@ -4,12 +4,8 @@ import "strings"
const
(
const
(
// Web search
// Web search
WebSearchHighTierModelPriceLow
=
30.00
WebSearchPriceHigh
=
25.00
WebSearchHighTierModelPriceMedium
=
35.00
WebSearchPrice
=
10.00
WebSearchHighTierModelPriceHigh
=
50.00
WebSearchPriceLow
=
25.00
WebSearchPriceMedium
=
27.50
WebSearchPriceHigh
=
30.00
// File search
// File search
FileSearchPrice
=
2.5
FileSearchPrice
=
2.5
)
)
...
@@ -34,38 +30,18 @@ func GetClaudeWebSearchPricePerThousand() float64 {
...
@@ -34,38 +30,18 @@ func GetClaudeWebSearchPricePerThousand() float64 {
func
GetWebSearchPricePerThousand
(
modelName
string
,
contextSize
string
)
float64
{
func
GetWebSearchPricePerThousand
(
modelName
string
,
contextSize
string
)
float64
{
// 确定模型类型
// 确定模型类型
// https://platform.openai.com/docs/pricing Web search 价格按模型类型和 search context size 收费
// https://platform.openai.com/docs/pricing Web search 价格按模型类型收费
// gpt-4.1, gpt-4o, or gpt-4o-search-preview 更贵,gpt-4.1-mini, gpt-4o-mini, gpt-4o-mini-search-preview 更便宜
// 新版计费规则不再关联 search context size,故在const区域将各size的价格设为一致。
isHighTierModel
:=
(
strings
.
HasPrefix
(
modelName
,
"gpt-4.1"
)
||
strings
.
HasPrefix
(
modelName
,
"gpt-4o"
))
&&
// gpt-4o and gpt-4.1 models (including mini models) 等模型更贵,o3, o4-mini, o3-pro, and deep research models 等模型更便宜
!
strings
.
Contains
(
modelName
,
"mini"
)
isNormalPriceModel
:=
// 确定 search context size 对应的价格
strings
.
HasPrefix
(
modelName
,
"o3"
)
||
strings
.
HasPrefix
(
modelName
,
"o4"
)
||
strings
.
Contains
(
modelName
,
"deep-research"
)
var
priceWebSearchPerThousandCalls
float64
var
priceWebSearchPerThousandCalls
float64
switch
contextSize
{
if
isNormalPriceModel
{
case
"low"
:
priceWebSearchPerThousandCalls
=
WebSearchPrice
if
isHighTierModel
{
}
else
{
priceWebSearchPerThousandCalls
=
WebSearchHighTierModelPriceLow
priceWebSearchPerThousandCalls
=
WebSearchPriceHigh
}
else
{
priceWebSearchPerThousandCalls
=
WebSearchPriceLow
}
case
"medium"
:
if
isHighTierModel
{
priceWebSearchPerThousandCalls
=
WebSearchHighTierModelPriceMedium
}
else
{
priceWebSearchPerThousandCalls
=
WebSearchPriceMedium
}
case
"high"
:
if
isHighTierModel
{
priceWebSearchPerThousandCalls
=
WebSearchHighTierModelPriceHigh
}
else
{
priceWebSearchPerThousandCalls
=
WebSearchPriceHigh
}
default
:
// search context size 默认为 medium
if
isHighTierModel
{
priceWebSearchPerThousandCalls
=
WebSearchHighTierModelPriceMedium
}
else
{
priceWebSearchPerThousandCalls
=
WebSearchPriceMedium
}
}
}
return
priceWebSearchPerThousandCalls
return
priceWebSearchPerThousandCalls
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment