Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/QuantumNous/new-api
/ functions
Functions
10,934 in github.com/QuantumNous/new-api
⨍
Functions
10,934
◇
Types & classes
1,622
↓ 5 callers
Function
CountTextToken
CountTextToken 统计文本的token数量,仅OpenAI模型使用tokenizer,其余模型使用估算
service/token_counter.go:402
↓ 5 callers
Function
CreateBodyStorage
CreateBodyStorage 根据数据大小创建合适的存储
common/body_storage.go:286
↓ 5 callers
Method
DefinedModes
DefinedModes returns each distinct mode on the protocol in host-table order.
pkg/jsplugin/routing.go:120
↓ 5 callers
Method
Delete
()
model/channel.go:625
↓ 5 callers
Function
DispatchPlatformUpdate
DispatchPlatformUpdate 按平台分发轮询更新
service/task_polling.go:195
↓ 5 callers
Function
EnableWorker
()
setting/system_setting/system_setting_old.go:9
↓ 5 callers
Method
Flush
()
router/plugin-router.go:452
↓ 5 callers
Function
GenerateTextOtherInfo
(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, modelRatio, groupRatio, completionRatio float64, cacheTo
service/log_info_generate.go:72
↓ 5 callers
Function
GetAudioCompletionRatio
(name string)
setting/ratio_setting/model_ratio.go:614
↓ 5 callers
Function
GetAudioRatio
(name string)
setting/ratio_setting/model_ratio.go:606
↓ 5 callers
Function
GetBillingMode
--------------------------------------------------------------------------- Read accessors (hot path, must be fast) ----------------------------------
setting/billing_setting/tiered_billing.go:45
↓ 5 callers
Method
GetCacheCreation1hTokens
()
relaykit/dto/claude.go:581
↓ 5 callers
Method
GetCacheCreation5mTokens
()
relaykit/dto/claude.go:574
↓ 5 callers
Method
GetChannelName
()
relay/channel/adapter.go:31
↓ 5 callers
Function
GetCompletionRatio
(name string)
setting/ratio_setting/model_ratio.go:419
↓ 5 callers
Function
GetConsoleSetting
GetConsoleSetting 获取 ConsoleSetting 配置实例
setting/console_setting/config.go:37
↓ 5 callers
Function
GetContextKeyType
(c *gin.Context, key constant.ContextKey)
common/gin.go:189
↓ 5 callers
Function
GetDiskCacheDir
GetDiskCacheDir 获取统一的磁盘缓存目录 注意:每次调用都会重新计算,以响应配置变化
common/disk_cache.go:25
↓ 5 callers
Function
GetDiskCachePath
GetDiskCachePath 获取磁盘缓存目录
common/disk_cache_config.go:65
↓ 5 callers
Function
GetEpayClient
()
controller/topup.go:136
↓ 5 callers
Function
GetGroupGroupRatio
(userGroup, usingGroup string)
setting/ratio_setting/group_ratio.go:88
↓ 5 callers
Method
GetMaskedKey
()
model/token.go:80
↓ 5 callers
Function
GetModelPrice
GetModelPrice 返回模型的价格,如果模型不存在则返回-1,false
setting/ratio_setting/model_ratio.go:360
↓ 5 callers
Method
GetNextEnabledKey
()
model/channel.go:204
↓ 5 callers
Method
GetPage
()
common/page_info.go:29
↓ 5 callers
Function
GetTaskPluginSyncSnapshot
GetTaskPluginSyncSnapshot returns the enabled override set together with a deterministic revision of every active database override. Nodes can compare
model/task_plugin.go:122
↓ 5 callers
Function
GetTokenById
(id int)
model/token.go:270
↓ 5 callers
Method
GetTokenCountMeta
()
relaykit/dto/request_common.go:9
↓ 5 callers
Function
GetToolPrice
GetToolPrice is a convenience wrapper when no model name is needed.
setting/operation_setting/tools.go:217
↓ 5 callers
Function
GetToolPriceForModel
GetToolPriceForModel returns the price ($/1K calls) for a tool given a model name. Lookup: longest prefix match → tool default → 0.
setting/operation_setting/tools.go:192
↓ 5 callers
Function
GetUserUsableGroups
(userGroup string)
service/group.go:14
↓ 5 callers
Function
GetUsernameById
GetUsernameById gets username from Redis first, falls back to DB if needed
model/user.go:1425
↓ 5 callers
Function
HasGeminiUsageMetadataTokens
(metadata *GeminiUsageMetadata)
relaykit/dto/billing_usage.go:190
↓ 5 callers
Function
HostProtocol
(name string)
pkg/jsplugin/routing.go:93
↓ 5 callers
Method
Insert
()
model/subscription.go:230
↓ 5 callers
Function
IssueAccessToken
(identity AuthIdentity)
service/auth_token.go:60
↓ 5 callers
Method
ListArtifacts
(task *model.Task)
relay/channel/adapter.go:104
↓ 5 callers
Function
ListModels
(c *gin.Context, modelType int)
controller/model.go:218
↓ 5 callers
Function
LoadFileSource
LoadFileSource 加载文件源数据 这是统一的入口,会自动处理缓存和不同的来源类型
service/file_service.go:47
↓ 5 callers
Method
LookupDeclaredRoute
LookupDeclaredRoute resolves a manifest path declaration. It does not match an incoming concrete URL; runtime matching is delegated to Gin.
pkg/jsplugin/routing.go:437
↓ 5 callers
Function
NewFileSourceFromData
(data string, mimeType string)
relaykit/types/file_source.go:134
↓ 5 callers
Function
NewGeminiChatBillingUsage
(metadata *GeminiUsageMetadata)
relaykit/dto/billing_usage.go:106
↓ 5 callers
Function
NewRWMap
()
types/rw_map.go:27
↓ 5 callers
Function
NewUserSortOptions
(sortBy string, sortOrder string)
model/user.go:36
↓ 5 callers
Function
OaiResponsesStreamHandler
(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response)
relay/channel/openai/relay_responses.go:75
↓ 5 callers
Function
OaiStreamHandler
(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response)
relay/channel/openai/relay-openai.go:104
↓ 5 callers
Function
OpenAIChatRequestToClaudeMessages
(c context.Context, info convmeta.Meta, textRequest dto.GeneralOpenAIRequest)
relaykit/relayconvert/request_compat.go:18
↓ 5 callers
Function
OpenaiImageHandler
OpenaiImageHandler handles non-streaming OpenAI image responses (generations/edits), returning the parsed usage for billing.
relay/channel/openai/relay_image.go:34
↓ 5 callers
Method
Plugins
()
pkg/jsplugin/routing.go:483
↓ 5 callers
Function
PreConsumeBilling
PreConsumeBilling 根据用户计费偏好创建 BillingSession 并执行预扣费。 会话存储在 relayInfo.Billing 上,供后续 Settle / Refund 使用。
service/billing.go:20
↓ 5 callers
Method
ProtocolSupports
ProtocolSupports reports whether the named protocol claim includes mode.
pkg/jsplugin/registry.go:97
↓ 5 callers
Function
RecordTopupLog
(userId int, content string, callerIp string, paymentMethod string, callbackPaymentMethod string)
model/log.go:269
↓ 5 callers
Function
Register
Register registers an OAuth provider with the given name
oauth/registry.go:19
↓ 5 callers
Function
RelayTaskSubmit
RelayTaskSubmit 完成 task 提交的全部流程(每次尝试调用一次): 刷新渠道元数据 → 确定 platform/adaptor → 验证请求 → 估算计费(EstimateBilling) → 计算价格 → 预扣费(仅首次)→ 构建/发送/解析上游请求 → 提交后计费调整(Adju
relay/relay_task.go:196
↓ 5 callers
Function
ResponseChunkData
(c *gin.Context, resp dto.ResponsesStreamResponse, data string)
relay/helper/common.go:87
↓ 5 callers
Function
RevokeUserSession
(userID int, sid, reason string)
model/user_session.go:544
↓ 5 callers
Method
SetAutoGroups
(groups []string)
model/token.go:46
↓ 5 callers
Method
SetModelName
(modelName string)
relaykit/dto/request_common.go:11
↓ 5 callers
Method
SetSetting
(setting dto.UserSetting)
model/user.go:169
↓ 5 callers
Function
SetupContextForToken
(c *gin.Context, token *model.Token, parts ...string)
middleware/auth.go:488
↓ 5 callers
Function
Sha1
(data []byte)
common/hash.go:22
↓ 5 callers
Function
ShouldPreserveThinkingSuffix
ShouldPreserveThinkingSuffix 判断模型是否配置为保留 thinking/-nothinking/-low/-high/-medium 后缀
setting/model_setting/global.go:67
↓ 5 callers
Function
StrToMap
(str string)
common/str.go:47
↓ 5 callers
Function
TaskArtifactContent
(c *gin.Context)
controller/task.go:279
↓ 5 callers
Method
ToResponse
()
model/system_task.go:416
↓ 5 callers
Function
TryReserveUserQuota
TryReserveUserQuota atomically checks and deducts a user's wallet quota. 缓存命中时以缓存余额为准(避免批量模式下过期的数据库余额放大并发超扣); Redis 异常或水合失败时降级为数据库条件更新,保证服务可用。
model/quota_reserve.go:165
↓ 5 callers
Method
Update
()
model/subscription.go:237
↓ 5 callers
Method
Update
()
model/channel.go:556
↓ 5 callers
Method
UpdateAbilities
UpdateAbilities updates abilities of this channel. Make sure the channel is completed before calling this function.
model/ability.go:263
↓ 5 callers
Function
UpdateModelRatioByJSONString
(jsonStr string)
setting/ratio_setting/model_ratio.go:373
↓ 5 callers
Function
UpdateUserBindColumn
UpdateUserBindColumn 第三方账号绑定字段的专用更新。 绑定操作必须只写绑定列:若改为“读取完整用户 → 改一个字段 → 整体更新”, 读快照期间并发发生的封禁、降权或分组变更会被旧快照覆盖恢复。 角色、状态、分组只允许通过各自带锁/CAS 的专用方法修改。
model/user.go:207
↓ 5 callers
Function
UploadTaskPlugin
(c *gin.Context)
controller/task_plugin.go:36
↓ 5 callers
Function
UsageFromGeminiMetadata
(metadata *dto.GeminiUsageMetadata, fallbackPromptTokens int)
relaykit/relayconvert/response_compat.go:71
↓ 5 callers
Function
ValidateConsoleSettings
(settingsStr string, settingType string)
setting/console_setting/validation.go:68
↓ 5 callers
Function
allowPrivateTaskMediaTest
(t *testing.T)
controller/task_generic_test.go:57
↓ 5 callers
Function
applyAuthBundle
( bundle: AuthBundle, synchronizeTabs = true )
web/src/lib/auth-session.ts:148
↓ 5 callers
Function
applyUsagePostProcessing
(info *relaycommon.RelayInfo, usage *dto.Usage, responseBody []byte)
relay/channel/openai/usage.go:10
↓ 5 callers
Function
asciiFold
asciiFold maps only 'A'–'Z' onto 'a'–'z'. Every other byte is unchanged. Unicode case folding is intentionally not applied: U+212A (KELVIN SIGN) must
pkg/jsplugin/model_fold.go:6
↓ 5 callers
Function
authRotationData
(bundle *service.AuthBundle)
controller/auth_session.go:182
↓ 5 callers
Function
buildChannelAffinityTemplateContextForTest
(meta channelAffinityMeta)
service/channel_affinity_template_test.go:17
↓ 5 callers
Function
buildOpenAIStyleUsageFromClaudeUsage
(usage *dto.Usage)
relay/channel/claude/relay-claude.go:56
↓ 5 callers
Function
buildQueryParams
buildQueryParams builds query parameters for GET requests
pkg/ionet/client.go:161
↓ 5 callers
Function
cacheGetTokenByKey
cacheGetTokenByKey 从缓存读取 token;不完整的哈希(如仅有配额字段)会被拒绝。
model/token_cache.go:94
↓ 5 callers
Function
cacheGetUserBase
(userId int)
model/user_cache.go:117
↓ 5 callers
Function
callback
(authorization: unknown)
web/src/features/auth/components/telegram-login-dialog.tsx:56
↓ 5 callers
Function
canonicalUsageFromResponse
(response any)
relaykit/relayconvert/response_registry.go:739
↓ 5 callers
Function
channelMatchesExpectedTaskPlugin
(c *gin.Context, channel *model.Channel, expected string)
middleware/distributor.go:207
↓ 5 callers
Function
colorAt
(index: number, palette?: readonly string[])
web/src/features/dashboard/lib/flow.ts:279
↓ 5 callers
Function
completeAssistantTiming
( message: Message, completedAt: number = Date.now() )
web/src/features/playground/lib/message/message-timing-utils.ts:22
↓ 5 callers
Function
configureTokenAutoGroupsTest
(t *testing.T, maxCount string, autoGroups string)
controller/token_auto_groups_test.go:19
↓ 5 callers
Function
confirmPaymentComplianceForTest
(t *testing.T)
controller/payment_webhook_availability_test.go:11
↓ 5 callers
Function
createReserveTestUser
(t *testing.T, quota int)
model/quota_reserve_test.go:14
↓ 5 callers
Function
decodeData
(data []byte, target *T)
pkg/ionet/jsonutil.go:28
↓ 5 callers
Function
doRequest
(c *gin.Context, req *http.Request, info *common.RelayInfo)
relay/channel/api_request.go:490
↓ 5 callers
Method
ensureStart
()
relaykit/relayconvert/internal/oai_responses/to_oai_chat_stream_resp.go:139
↓ 5 callers
Function
evaluateTaskVisualConfig
( config: TaskVisualConfig, sample: Record<string, number | string>, schema?: BillingUsageSchema )
web/src/features/pricing/lib/task-expr.ts:280
↓ 5 callers
Function
formatQuotaWithCurrency
( quota: number | null | undefined, options?: CurrencyFormatOptions )
web/src/lib/currency.ts:516
↓ 5 callers
Function
getChannelAffinityMeta
(c *gin.Context)
service/channel_affinity.go:375
↓ 5 callers
Function
getChannelTypeIcon
(type: number)
web/src/features/channels/lib/channel-utils.ts:47
↓ 5 callers
Function
getChannelTypeLabel
(type: number)
web/src/features/channels/lib/channel-utils.ts:39
← previous
next →
701–800 of 10,934, ranked by callers