{"modulePath":"github.com/MAX-API-Next/MAX-API","version":"v1.0.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package operation_setting\n\n## Constants\n\n```go\nconst (\n\tQuotaDisplayTypeUSD    = \"USD\"\n\tQuotaDisplayTypeCNY    = \"CNY\"\n\tQuotaDisplayTypeTokens = \"TOKENS\"\n\tQuotaDisplayTypeCustom = \"CUSTOM\"\n)\n```\n额度展示类型\n\n```go\nconst (\n\tChannelTestModeScheduledAll    = \"scheduled_all\"\n\tChannelTestModePassiveRecovery = \"passive_recovery\"\n)\n```\n\n```go\nconst (\n\tGPTImage1Low1024x1024    = 0.011\n\tGPTImage1Low1024x1536    = 0.016\n\tGPTImage1Low1536x1024    = 0.016\n\tGPTImage1Medium1024x1024 = 0.042\n\tGPTImage1Medium1024x1536 = 0.063\n\tGPTImage1Medium1536x1024 = 0.063\n\tGPTImage1High1024x1024   = 0.167\n\tGPTImage1High1024x1536   = 0.25\n\tGPTImage1High1536x1024   = 0.25\n)\n```\n\n```go\nconst (\n\tGemini25FlashPreviewInputAudioPrice     = 1.00\n\tGemini25FlashProductionInputAudioPrice  = 1.00\n\tGemini25FlashLitePreviewInputAudioPrice = 0.50\n\tGemini25FlashNativeAudioInputAudioPrice = 3.00\n\tGemini20FlashInputAudioPrice            = 0.70\n\tGeminiRoboticsER15InputAudioPrice       = 1.00\n)\n```\n\n```go\nconst CurrentComplianceTermsVersion = \"v1\"\n```\n\n## Variables\n\n```go\nvar AutomaticDisableKeywords = []string{\n\t\"Your credit balance is too low\",\n\t\"This organization has been disabled.\",\n\t\"You exceeded your current quota\",\n\t\"Permission denied\",\n\t\"The security token included in the request is invalid\",\n\t\"Operation not allowed\",\n\t\"Your account is not authorized\",\n}\n```\n\n```go\nvar AutomaticDisableStatusCodeRanges = []StatusCodeRange{{Start: 401, End: 401}}\n```\n\n```go\nvar AutomaticRetryStatusCodeRanges = []StatusCodeRange{\n\t{Start: 100, End: 199},\n\t{Start: 300, End: 399},\n\t{Start: 401, End: 407},\n\t{Start: 409, End: 499},\n\t{Start: 500, End: 503},\n\t{Start: 505, End: 523},\n\t{Start: 525, End: 599},\n}\n```\nDefault behavior matches legacy hardcoded retry rules in controller/relay.go shouldRetry: retry for 1xx, 3xx, 4xx(except 400/408), 5xx(except 504/524), and no retry for 2xx.\n\n```go\nvar CustomCallbackAddress = \"\"\n```\n\n```go\nvar DemoSiteEnabled = false\n```\n\n```go\nvar EpayId = \"\"\n```\n\n```go\nvar EpayKey = \"\"\n```\n\n```go\nvar MinTopUp = 1\n```\n\n```go\nvar PayAddress = \"\"\n```\n\n```go\nvar PayMethods = []map[string]string{\n\t{\n\t\t\"name\":  \"支付宝\",\n\t\t\"color\": \"rgba(var(--semi-blue-5), 1)\",\n\t\t\"type\":  \"alipay\",\n\t},\n\t{\n\t\t\"name\":  \"微信\",\n\t\t\"color\": \"rgba(var(--semi-green-5), 1)\",\n\t\t\"type\":  \"wxpay\",\n\t},\n\t{\n\t\t\"name\":      \"自定义1\",\n\t\t\"color\":     \"black\",\n\t\t\"type\":      \"custom1\",\n\t\t\"min_topup\": \"50\",\n\t},\n}\n```\n\n```go\nvar Price = 7.3\n```\n\n```go\nvar SelfUseModeEnabled = false\n```\n\n```go\nvar USDExchangeRate = 7.3\n```\n\n## Functions\n\n```go\nfunc AutomaticDisableKeywordsFromString(s string)\n```\n\n```go\nfunc AutomaticDisableKeywordsToString() string\n```\n\n```go\nfunc AutomaticDisableStatusCodesFromString(s string) error\n```\n\n```go\nfunc AutomaticDisableStatusCodesToString() string\n```\n\n```go\nfunc AutomaticRetryStatusCodesFromString(s string) error\n```\n\n```go\nfunc AutomaticRetryStatusCodesToString() string\n```\n\n```go\nfunc ContainsPayMethod(method string) bool\n```\n\n```go\nfunc GetCheckinQuotaRange() (min, max int)\n```\nGetCheckinQuotaRange 获取签到额度范围\n\n```go\nfunc GetCurrencySymbol() string\n```\nGetCurrencySymbol 返回当前展示类型对应符号\n\n```go\nfunc GetGPTImage1PriceOnceCall(quality string, size string) float64\n```\n\n```go\nfunc GetGeminiInputAudioPricePerMillionTokens(modelName string) float64\n```\n\n```go\nfunc GetMaxUserTokens() int\n```\nGetMaxUserTokens 获取每用户最大令牌数量\n\n```go\nfunc GetQuotaDisplayType() string\n```\nGetQuotaDisplayType 返回额度展示类型\n\n```go\nfunc GetToolPrice(toolName string) float64\n```\nGetToolPrice is a convenience wrapper when no model name is needed.\n\n```go\nfunc GetToolPriceForModel(toolName, modelName string) float64\n```\nGetToolPriceForModel returns the price ($/1K calls) for a tool given a model name. Lookup: longest prefix match → tool default → 0.\n\n```go\nfunc GetUsdToCurrencyRate(usdToCny float64) float64\n```\nGetUsdToCurrencyRate 返回 1 USD = X \\\u003ccurrency\u003e 的 X（TOKENS 不适用）\n\n```go\nfunc IsAlwaysSkipRetryCode(errorCode types.ErrorCode) bool\n```\n\n```go\nfunc IsAlwaysSkipRetryStatusCode(code int) bool\n```\n\n```go\nfunc IsCNYDisplay() bool\n```\nIsCNYDisplay 是否以人民币展示\n\n```go\nfunc IsCheckinEnabled() bool\n```\nIsCheckinEnabled 是否启用签到功能\n\n```go\nfunc IsCurrencyDisplay() bool\n```\nIsCurrencyDisplay 是否以货币形式展示（美元或人民币）\n\n```go\nfunc IsPaymentComplianceConfirmed() bool\n```\n\n```go\nfunc PayMethods2JsonString() string\n```\n\n```go\nfunc RebuildToolPriceIndex()\n```\nRebuildToolPriceIndex rebuilds the lookup index from the current config. Called on init and after config updates. Not on the billing hot path.\n\n```go\nfunc ShouldDisableByStatusCode(code int) bool\n```\n\n```go\nfunc ShouldRetryByStatusCode(code int) bool\n```\n\n```go\nfunc UpdatePayMethodsByJsonString(jsonString string) error\n```\n\n## Types\n\n```go\ntype ChannelAffinityKeySource struct {\n\tType string `json:\"type\"` // context_int, context_string, request_header, gjson\n\tKey  string `json:\"key,omitempty\"`\n\tPath string `json:\"path,omitempty\"`\n}\n```\n\n```go\ntype ChannelAffinityRule struct {\n\tName             string                     `json:\"name\"`\n\tModelRegex       []string                   `json:\"model_regex\"`\n\tPathRegex        []string                   `json:\"path_regex\"`\n\tUserAgentInclude []string                   `json:\"user_agent_include,omitempty\"`\n\tKeySources       []ChannelAffinityKeySource `json:\"key_sources\"`\n\n\tValueRegex string `json:\"value_regex\"`\n\tTTLSeconds int    `json:\"ttl_seconds\"`\n\n\tParamOverrideTemplate map[string]interface{} `json:\"param_override_template,omitempty\"`\n\n\tSkipRetryOnFailure bool `json:\"skip_retry_on_failure\"`\n\n\tIncludeUsingGroup bool `json:\"include_using_group\"`\n\tIncludeModelName  bool `json:\"include_model_name\"`\n\tIncludeRuleName   bool `json:\"include_rule_name\"`\n}\n```\n\n```go\ntype ChannelAffinitySetting struct {\n\tEnabled               bool                  `json:\"enabled\"`\n\tSwitchOnSuccess       bool                  `json:\"switch_on_success\"`\n\tKeepOnChannelDisabled bool                  `json:\"keep_on_channel_disabled\"`\n\tMaxEntries            int                   `json:\"max_entries\"`\n\tDefaultTTLSeconds     int                   `json:\"default_ttl_seconds\"`\n\tRules                 []ChannelAffinityRule `json:\"rules\"`\n}\n```\n\n```go\nfunc GetChannelAffinitySetting() *ChannelAffinitySetting\n```\n\n```go\ntype CheckinSetting struct {\n\tEnabled  bool `json:\"enabled\"`   // 是否启用签到功能\n\tMinQuota int  `json:\"min_quota\"` // 签到最小额度奖励\n\tMaxQuota int  `json:\"max_quota\"` // 签到最大额度奖励\n}\n```\nCheckinSetting 签到功能配置\n\n```go\nfunc GetCheckinSetting() *CheckinSetting\n```\nGetCheckinSetting 获取签到配置\n\n```go\ntype GeneralSetting struct {\n\tDocsLink            string `json:\"docs_link\"`\n\tPingIntervalEnabled bool   `json:\"ping_interval_enabled\"`\n\tPingIntervalSeconds int    `json:\"ping_interval_seconds\"`\n\t// 当前站点额度展示类型：USD / CNY / TOKENS\n\tQuotaDisplayType string `json:\"quota_display_type\"`\n\t// 自定义货币符号，用于 CUSTOM 展示类型\n\tCustomCurrencySymbol string `json:\"custom_currency_symbol\"`\n\t// 自定义货币与美元汇率（1 USD = X Custom）\n\tCustomCurrencyExchangeRate float64 `json:\"custom_currency_exchange_rate\"`\n}\n```\n\n```go\nfunc GetGeneralSetting() *GeneralSetting\n```\n\n```go\ntype MonitorSetting struct {\n\tAutoTestChannelEnabled bool    `json:\"auto_test_channel_enabled\"`\n\tAutoTestChannelMinutes float64 `json:\"auto_test_channel_minutes\"`\n\tChannelTestMode        string  `json:\"channel_test_mode\"`\n}\n```\n\n```go\nfunc GetMonitorSetting() *MonitorSetting\n```\n\n```go\ntype PaymentSetting struct {\n\tAmountOptions  []int           `json:\"amount_options\"`\n\tAmountDiscount map[int]float64 `json:\"amount_discount\"` // 充值金额对应的折扣，例如 100 元 0.9 表示 100 元充值享受 9 折优惠\n\n\tComplianceConfirmed    bool   `json:\"compliance_confirmed\"`\n\tComplianceTermsVersion string `json:\"compliance_terms_version\"`\n\tComplianceConfirmedAt  int64  `json:\"compliance_confirmed_at\"`\n\tComplianceConfirmedBy  int    `json:\"compliance_confirmed_by\"`\n\tComplianceConfirmedIP  string `json:\"compliance_confirmed_ip\"`\n}\n```\n\n```go\nfunc GetPaymentSetting() *PaymentSetting\n```\n\n```go\ntype QuotaSetting struct {\n\tEnableFreeModelPreConsume bool `json:\"enable_free_model_pre_consume\"` // 是否对免费模型启用预消耗\n}\n```\n\n```go\nfunc GetQuotaSetting() *QuotaSetting\n```\n\n```go\ntype StatusCodeRange struct {\n\tStart int\n\tEnd   int\n}\n```\n\n```go\nfunc ParseHTTPStatusCodeRanges(input string) ([]StatusCodeRange, error)\n```\n\n```go\ntype TokenSetting struct {\n\tMaxUserTokens int `json:\"max_user_tokens\"` // 每用户最大令牌数量\n}\n```\nTokenSetting 令牌相关配置\n\n```go\nfunc GetTokenSetting() *TokenSetting\n```\nGetTokenSetting 获取令牌配置\n\n```go\ntype ToolPriceSetting struct {\n\tPrices map[string]float64 `json:\"prices\"`\n}\n```\nToolPriceSetting is managed by config.GlobalConfig.Register.\n\n","path":"github.com/MAX-API-Next/MAX-API/setting/operation_setting","name":"operation_setting","synopsis":"","isRedistributable":true}
