MCPcopy Create free account

hub / github.com/QuantumNous/new-api / functions

Functions9,732 in github.com/QuantumNous/new-api

↓ 9 callersFunctionRefundTaskQuota
RefundTaskQuota 统一的任务失败退款逻辑。 当异步任务失败时,退还资金与令牌额度,并回减用户和渠道用量。 返回资金来源是否已成功退还;失败时保留 quota,供显式重试或人工对账。
service/task_billing.go:166
↓ 9 callersFunctionRevokeAllUserSessions
(userID int, reason string)
model/user_session.go:708
↓ 9 callersFunctionSetDatabaseTypes
(mainType DatabaseType, logType DatabaseType)
common/database.go:31
↓ 9 callersFunctionStringData
(c *gin.Context, str string)
relay/helper/common.go:97
↓ 9 callersMethodToOpenAIError
()
relaykit/types/error.go:180
↓ 9 callersMethodType
()
service/system_task.go:35
↓ 9 callersFunctionUpdateMaxTokenAutoGroups
(value string)
setting/auto_group.go:63
↓ 9 callersMethodUpdateWithStatus
UpdateWithStatus performs a conditional UPDATE guarded by fromStatus (CAS). Returns (true, nil) if this caller won the update, (false, nil) if another
model/task.go:423
↓ 9 callersFunctionUsedVars
UsedVars returns the set of identifier names referenced by an expression. The result is cached alongside the compiled program. Returns nil for empty i
pkg/billingexpr/compile.go:249
↓ 9 callersFunctionUserSubject
UserSubject is the casbin subject string for a single user.
service/authz/permission.go:20
↓ 9 callersMethodValue
()
model/task.go:96
↓ 9 callersFunctionaddNewRecord
(type_ int, id int, value int)
model/utils.go:42
↓ 9 callersMethodconvertToAliRequest
(info *relaycommon.RelayInfo, req relaycommon.TaskSubmitReq)
relay/channel/task/ali/adaptor.go:351
↓ 9 callersFunctionfetchChannelUpstreamModelIDs
(channel *model.Channel)
controller/channel_upstream_update.go:363
↓ 9 callersFunctiongetChannelAffinityCache
()
service/channel_affinity.go:81
↓ 9 callersFunctiongetUserAuthFenceKey
(userId int)
model/user_auth_cache.go:26
↓ 9 callersFunctionisAuthBundle
(value: unknown)
web/src/lib/auth-session.ts:129
↓ 9 callersFunctionparseQuotaFromDollars
(amount: number)
web/src/lib/format.ts:84
↓ 9 callersFunctionpopulateUserCache
(user User)
model/user_cache.go:70
↓ 9 callersFunctionrecordManageAuditFor
recordManageAuditFor 记录一条管理审计日志,日志归属于操作者;targetUserId 只表示被操作用户,用于在结构化参数中保留目标上下文。
controller/audit.go:99
↓ 9 callersFunctionsafeNumberFieldProps
(field: ControllerRenderProps<TFieldValues, TName>)
web/src/features/system-settings/utils/numeric-field.ts:76
↓ 9 callersFunctionstreamValuesFromAny
(value any)
relaykit/relayconvert/response_registry.go:626
↓ 9 callersFunctionuseApiKeys
()
web/src/features/keys/components/api-keys-provider.tsx:182
↓ 9 callersFunctionuseIsMobile
()
web/src/hooks/use-mobile.ts:23
↓ 9 callersFunctionuseModels
()
web/src/features/models/components/models-provider.tsx:131
↓ 9 callersFunctionuseThemeCustomization
()
web/src/context/theme-customization-provider.tsx:260
↓ 8 callersMethodClose
()
relay/channel/openai/image_stream_test.go:165
↓ 8 callersMethodConvertOpenAIRequest
(c *gin.Context, info *relaycommon.RelayInfo, request *dto.GeneralOpenAIRequest)
relay/channel/adapter.go:21
↓ 8 callersFunctionConvertStreamResponseChunk
(c context.Context, info convmeta.Meta, state *ResponseStreamState, response any)
relaykit/relayconvert/response_registry.go:301
↓ 8 callersMethodDeleteMany
DeleteMany accepts either fully namespaced keys or raw keys and deletes them. It returns a map keyed by fully namespaced keys.
pkg/cachex/hybrid_cache.go:231
↓ 8 callersFunctionFinalizeStreamResponse
(c context.Context, info convmeta.Meta, state *ResponseStreamState)
relaykit/relayconvert/response_registry.go:326
↓ 8 callersFunctionFlushWriter
(c *gin.Context)
relay/helper/common.go:17
↓ 8 callersFunctionGetFetchSetting
()
setting/system_setting/fetch_setting.go:32
↓ 8 callersFunctionGetGeminiSettings
GetGeminiSettings 获取Gemini配置
setting/model_setting/gemini.go:65
↓ 8 callersFunctionGetOIDCSettings
()
setting/system_setting/oidc.go:28
↓ 8 callersFunctionGetSystemTaskByTaskID
(taskID string)
model/system_task.go:121
↓ 8 callersFunctionGetTopUpByTradeNo
(tradeNo string)
model/topup.go:135
↓ 8 callersFunctionGetUUID
()
relaykit/relayconvert/kitutil/value.go:44
↓ 8 callersMethodHasChannelMeta
HasChannelMeta reports whether upstream channel information is attached; converters use it to decide if GetUpstreamModelName is meaningful.
relaykit/relayconvert/convmeta/meta.go:23
↓ 8 callersFunctionNewOpenAIChatBillingUsage
(usage *Usage)
relaykit/dto/billing_usage.go:56
↓ 8 callersFunctionNewResponseStreamState
(from types.RelayFormat, target types.RelayFormat, options ResponseStreamOptions)
relaykit/relayconvert/response_registry.go:272
↓ 8 callersFunctionOaiResponsesHandler
(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response)
relay/channel/openai/relay_responses.go:20
↓ 8 callersFunctionOpenaiImageStreamHandler
(c *gin.Context, info *relaycommon.RelayInfo, resp *http.Response)
relay/channel/openai/relay_image.go:93
↓ 8 callersFunctionParseAccessToken
(raw string)
service/auth_token.go:85
↓ 8 callersFunctionPrepareMidjourneyTaskBilling
PrepareMidjourneyTaskBilling sets the durable refund marker before the task is inserted.
service/midjourney.go:35
↓ 8 callersMethodRead
(p []byte)
common/body_storage.go:196
↓ 8 callersFunctionRecalculateTaskQuota
RecalculateTaskQuota 通用的异步差额结算。 actualQuota 是任务完成后的实际应扣额度,与预扣额度 (task.Quota) 做差额结算。 reason 用于日志记录(例如 "token重算" 或 "adaptor调整")。 clamps 可选:若计算 actualQuo
service/task_billing.go:214
↓ 8 callersFunctionRecordConsumeLog
(c *gin.Context, userId int, params RecordConsumeLogParams)
model/log.go:343
↓ 8 callersMethodRecordError
(msg string)
relay/common/stream_status.go:55
↓ 8 callersFunctionResetProxyClientCache
ResetProxyClientCache clears cached proxy and non-default direct policy clients and closes idle connections on every transport/shard. The package-leve
service/http_client.go:430
↓ 8 callersMethodSetEstimatePromptTokens
func (info *RelayInfo) SetPromptTokens(promptTokens int) { info.promptTokens = promptTokens }
relay/common/relay_info.go:714
↓ 8 callersMethodSetProgressStr
(progress string)
relaykit/dto/openai_video.go:33
↓ 8 callersFunctionSetToolPriceForTest
SetToolPriceForTest injects a tool price and rebuilds the lookup index. Tests only.
setting/operation_setting/tools.go:222
↓ 8 callersFunctionT
T translates a message key using the language from gin context
i18n/i18n.go:90
↓ 8 callersFunctionUpdateUserUsableGroupsByJSONString
(jsonStr string)
setting/user_usable_group.go:38
↓ 8 callersFunctionValidateSSRFProtectedFetchURL
(urlStr string)
service/http_client.go:70
↓ 8 callersFunctioncalculateTextToolCallSurcharge
(ctx *gin.Context, relayInfo *relaycommon.RelayInfo, summary *textQuotaSummary)
service/text_quota.go:148
↓ 8 callersFunctioncanManageTargetRole
(myRole int, targetRole int)
controller/user.go:371
↓ 8 callersFunctioncreateLog
(log *Log)
model/log.go:101
↓ 8 callersFunctiondefaultHTTPTransportPolicy
()
service/http_transport_policy.go:22
↓ 8 callersFunctiongetTokenUsedQuota
(t *testing.T, id int)
service/task_billing_test.go:289
↓ 8 callersFunctiongetUserAuthVersionKey
(userId int)
model/user_auth_cache.go:30
↓ 8 callersFunctionhasParsedChildren
( node: ParsedNode )
web/src/components/ai-elements/response-node-guards.ts:36
↓ 8 callersFunctionisTagAggregateRow
(row: Channel | TagRow)
web/src/features/channels/lib/channel-utils.ts:617
↓ 8 callersMethodmemCache
()
pkg/cachex/hybrid_cache.go:69
↓ 8 callersFunctionmetricValue
(metrics: FlowMetrics, metric: FlowMetric)
web/src/features/dashboard/lib/flow.ts:164
↓ 8 callersFunctionnewImageTestContext
(t *testing.T, body, contentType string, isStream bool)
relay/channel/openai/image_stream_test.go:19
↓ 8 callersFunctionnewTestResponsesStreamState
()
relaykit/relayconvert/internal/oai_responses/to_oai_chat_resp_test.go:436
↓ 8 callersFunctionnormalizeHeaderContextKey
(key string)
relay/common/override.go:1558
↓ 8 callersMethodredisOn
()
pkg/cachex/hybrid_cache.go:59
↓ 8 callersFunctionrequireDeploymentID
(c *gin.Context)
controller/deployment.go:120
↓ 8 callersFunctionresetPricingEndpointTestTables
(t *testing.T)
model/pricing_endpoint_test.go:14
↓ 8 callersFunctionresetSessionCookieSettingsAfterTest
(t *testing.T)
common/url_validator_test.go:125
↓ 8 callersFunctionstaticProtection
(protection *common.SSRFProtection)
service/protected_fetch_client_test.go:26
↓ 8 callersFunctiontieredQuota
--------------------------------------------------------------------------- BuildTieredTokenParams: token normalization and ratio parity tests -------
service/tiered_settle_test.go:664
↓ 8 callersFunctionuseContextValue
()
web/src/components/ai-elements/context.tsx:52
↓ 8 callersFunctionuseRateLimitMiniRedis
(t *testing.T)
middleware/rate_limit_test.go:20
↓ 8 callersFunctionuseSubscriptions
()
web/src/features/subscriptions/components/subscriptions-provider.tsx:82
↓ 8 callersFunctionuseSystemConfig
(options: UseSystemConfigOptions = {})
web/src/hooks/use-system-config.ts:144
↓ 8 callersFunctionuseUsageLogsContext
()
web/src/features/usage-logs/components/usage-logs-provider.tsx:78
↓ 7 callersFunctionConfigureTrustedProxies
(engine *gin.Engine)
middleware/trusted_proxies.go:22
↓ 7 callersMethodGetAutoBan
()
model/channel.go:338
↓ 7 callersFunctionGetContextKeyString
(c *gin.Context, key constant.ContextKey)
common/gin.go:165
↓ 7 callersFunctionGetGroupRatioCopy
()
setting/ratio_setting/group_ratio.go:62
↓ 7 callersMethodGetImageMedia
()
relaykit/dto/openai_request.go:327
↓ 7 callersFunctionGetModelRatio
(name string)
setting/ratio_setting/model_ratio.go:385
↓ 7 callersFunctionGetMonitorSetting
()
setting/operation_setting/monitor_setting.go:41
↓ 7 callersFunctionGetPasskeyByUserID
(userID int)
model/passkey.go:123
↓ 7 callersFunctionGetPaymentSetting
()
setting/operation_setting/payment_setting.go:29
↓ 7 callersMethodGetResultURL
GetResultURL 获取任务结果 URL(视频地址等) 新数据存在 PrivateData.ResultURL 中;旧数据回退到 FailReason(历史兼容)
model/task.go:136
↓ 7 callersFunctionGetSSRFProtectedHTTPClient
GetSSRFProtectedHTTPClient 返回带拨号时 SSRF 校验的客户端。 ssrfProtectedHTTPClient 由 InitHttpClient 在启动时初始化,运行期只读。
service/http_client.go:136
↓ 7 callersMethodGetUpstreamModelName
()
relaykit/relayconvert/convmeta/meta.go:20
↓ 7 callersMethodGetUsageMetadata
()
relaykit/dto/gemini.go:496
↓ 7 callersFunctionGetUserSessionCached
GetUserSessionCached validates cached state first and falls back to the database on a miss or Redis read failure. A deny tombstone never falls back.
model/user_session.go:211
↓ 7 callersFunctionHeaderNavModuleAuth
(module string)
middleware/header_nav.go:104
↓ 7 callersMethodIsNormalEnd
()
relay/common/stream_status.go:88
↓ 7 callersFunctionIssueSecurityProof
(identity AuthIdentity, method string, scopes []string)
service/auth_token.go:132
↓ 7 callersFunctionLoadFromJsonStringWithCallback
(m *RWMap[K, V], jsonStr string, onSuccess func())
types/rw_map.go:83
↓ 7 callersFunctionLogDatabaseType
()
common/database.go:19
↓ 7 callersFunctionModelPriceHelper
(c *gin.Context, info *relaycommon.RelayInfo, promptTokens int, meta *types.TokenCountMeta)
relay/helper/price.go:73
← previousnext →301–400 of 9,732, ranked by callers