Documentation
¶
Index ¶
Constants ¶
const ( APITypeOpenAI = iota APITypeAnthropic APITypePaLM APITypeBaidu APITypeZhipu APITypeAli APITypeXunfei APITypeAIProxyLibrary APITypeTencent APITypeGemini APITypeZhipuV4 APITypeOllama APITypePerplexity APITypeAws APITypeCohere APITypeDify APITypeJina APITypeCloudflare APITypeSiliconFlow APITypeVertexAi APITypeMistral APITypeDeepSeek APITypeMokaAI APITypeVolcEngine APITypeBaiduV2 APITypeOpenRouter APITypeXinference APITypeXai APITypeCoze APITypeJimeng APITypeMoonshot APITypeSubmodel APITypeMiniMax APITypeReplicate APITypeCodex APITypeAdvancedCustom APITypeSub2API APITypeNewAPI APITypeDummy // this one is only for count, do not add any channel after this )
const ( UserGroupKeyFmt = "user_group:%d" UserQuotaKeyFmt = "user_quota:%d" UserEnabledKeyFmt = "user_enabled:%d" UserUsernameKeyFmt = "user_name:%d" )
Cache keys
const ( TokenFiledRemainQuota = "RemainQuota" TokenFieldGroup = "Group" )
const ( ChannelTypeUnknown = 0 ChannelTypeOpenAI = 1 ChannelTypeMidjourney = 2 ChannelTypeAzure = 3 ChannelTypeOllama = 4 ChannelTypeMidjourneyPlus = 5 ChannelTypeOpenAIMax = 6 ChannelTypeOhMyGPT = 7 ChannelTypeCustom = 8 ChannelTypeAILS = 9 ChannelTypeAIProxy = 10 ChannelTypePaLM = 11 ChannelTypeAPI2GPT = 12 ChannelTypeAIGC2D = 13 ChannelTypeAnthropic = 14 ChannelTypeBaidu = 15 ChannelTypeZhipu = 16 ChannelTypeAli = 17 ChannelTypeXunfei = 18 ChannelType360 = 19 ChannelTypeOpenRouter = 20 ChannelTypeAIProxyLibrary = 21 ChannelTypeFastGPT = 22 ChannelTypeTencent = 23 ChannelTypeGemini = 24 ChannelTypeMoonshot = 25 ChannelTypeZhipu_v4 = 26 ChannelTypePerplexity = 27 ChannelTypeLingYiWanWu = 31 ChannelTypeAws = 33 ChannelTypeCohere = 34 ChannelTypeMiniMax = 35 ChannelTypeSunoAPI = 36 ChannelTypeDify = 37 ChannelTypeJina = 38 ChannelCloudflare = 39 ChannelTypeSiliconFlow = 40 ChannelTypeVertexAi = 41 ChannelTypeMistral = 42 ChannelTypeDeepSeek = 43 ChannelTypeMokaAI = 44 ChannelTypeVolcEngine = 45 ChannelTypeBaiduV2 = 46 ChannelTypeXinference = 47 ChannelTypeXai = 48 ChannelTypeCoze = 49 ChannelTypeKling = 50 ChannelTypeJimeng = 51 ChannelTypeVidu = 52 ChannelTypeSubmodel = 53 ChannelTypeDoubaoVideo = 54 ChannelTypeSora = 55 ChannelTypeReplicate = 56 ChannelTypeCodex = 57 ChannelTypeAdvancedCustom = 58 ChannelTypeSub2API = 59 ChannelTypeNewAPI = 60 ChannelTypeTaskPlugin = 61 ChannelTypeDummy // this one is only for count, do not add any channel after this )
const ( EndpointTypeOpenAI = types.EndpointTypeOpenAI EndpointTypeOpenAIResponse = types.EndpointTypeOpenAIResponse EndpointTypeOpenAIResponseCompact = types.EndpointTypeOpenAIResponseCompact EndpointTypeOpenAIAlphaSearch = types.EndpointTypeOpenAIAlphaSearch EndpointTypeAnthropic = types.EndpointTypeAnthropic EndpointTypeGemini = types.EndpointTypeGemini EndpointTypeJinaRerank = types.EndpointTypeJinaRerank EndpointTypeImageGeneration = types.EndpointTypeImageGeneration EndpointTypeEmbeddings = types.EndpointTypeEmbeddings EndpointTypeOpenAIVideo = types.EndpointTypeOpenAIVideo )
const ( MjErrorUnknown = 5 MjRequestError = 4 )
const ( MjActionImagine = "IMAGINE" MjActionDescribe = "DESCRIBE" MjActionBlend = "BLEND" MjActionUpscale = "UPSCALE" MjActionVariation = "VARIATION" MjActionReRoll = "REROLL" MjActionInPaint = "INPAINT" MjActionModal = "MODAL" MjActionZoom = "ZOOM" MjActionCustomZoom = "CUSTOM_ZOOM" MjActionShorten = "SHORTEN" MjActionHighVariation = "HIGH_VARIATION" MjActionLowVariation = "LOW_VARIATION" MjActionPan = "PAN" MjActionSwapFace = "SWAP_FACE" MjActionUpload = "UPLOAD" MjActionVideo = "VIDEO" MjActionEdits = "EDITS" )
const ( TaskActionImageToVideo = "image_to_video" TaskActionTextToVideo = "text_to_video" TaskActionFirstTailToVideo = "first_tail_to_video" TaskActionReferenceToVideo = "reference_to_video" TaskActionRemix = "remix" )
Variables ¶
var ( FinishReasonStop = types.FinishReasonStop FinishReasonToolCalls = types.FinishReasonToolCalls FinishReasonLength = types.FinishReasonLength FinishReasonFunctionCall = types.FinishReasonFunctionCall FinishReasonContentFilter = types.FinishReasonContentFilter )
Finish reasons moved to types with the conversion kit.
var AnonymousRequestBodyLimitKB int
var AzureDefaultAPIVersion string
var ChannelBaseURLs = []string{
"",
"https://api.openai.com",
"https://oa.api2d.net",
"",
"http://localhost:11434",
"https://api.openai-sb.com",
"https://api.openaimax.com",
"https://api.ohmygpt.com",
"",
"https://api.caipacity.com",
"https://api.aiproxy.io",
"",
"https://api.api2gpt.com",
"https://api.aigc2d.com",
"https://api.anthropic.com",
"https://aip.baidubce.com",
"https://open.bigmodel.cn",
"https://dashscope.aliyuncs.com",
"",
"https://api.360.cn",
"https://openrouter.ai/api",
"https://api.aiproxy.io",
"https://fastgpt.run/api/openapi",
"https://hunyuan.tencentcloudapi.com",
"https://generativelanguage.googleapis.com",
"https://api.moonshot.cn",
"https://open.bigmodel.cn",
"https://api.perplexity.ai",
"",
"",
"",
"https://api.lingyiwanwu.com",
"",
"",
"https://api.cohere.ai",
"https://api.minimax.chat",
"",
"https://api.dify.ai",
"https://api.jina.ai",
"https://api.cloudflare.com",
"https://api.siliconflow.cn",
"",
"https://api.mistral.ai",
"https://api.deepseek.com",
"https://api.moka.ai",
"https://ark.cn-beijing.volces.com",
"https://qianfan.baidubce.com",
"",
"https://api.x.ai",
"https://api.coze.cn",
"https://api.klingai.com",
"https://visual.volcengineapi.com",
"https://api.vidu.cn",
"https://llm.submodel.ai",
"https://ark.cn-beijing.volces.com",
"https://api.openai.com",
"https://api.replicate.com",
"https://chatgpt.com",
"",
"",
"",
"",
}
var ChannelSpecialBases = map[string]ChannelSpecialBase{
"glm-coding-plan": {
ClaudeBaseURL: "https://open.bigmodel.cn/api/anthropic",
OpenAIBaseURL: "https://open.bigmodel.cn/api/coding/paas/v4",
},
"glm-coding-plan-international": {
ClaudeBaseURL: "https://api.z.ai/api/anthropic",
OpenAIBaseURL: "https://api.z.ai/api/coding/paas/v4",
},
"kimi-coding-plan": {
ClaudeBaseURL: "https://api.kimi.com/coding",
OpenAIBaseURL: "https://api.kimi.com/coding/v1",
},
"doubao-coding-plan": {
ClaudeBaseURL: "https://ark.cn-beijing.volces.com/api/coding",
OpenAIBaseURL: "https://ark.cn-beijing.volces.com/api/coding/v3",
},
}
var ChannelTypeNames = map[int]string{ ChannelTypeUnknown: "Unknown", ChannelTypeOpenAI: "OpenAI", ChannelTypeMidjourney: "Midjourney", ChannelTypeAzure: "Azure", ChannelTypeOllama: "Ollama", ChannelTypeMidjourneyPlus: "MidjourneyPlus", ChannelTypeOpenAIMax: "OpenAIMax", ChannelTypeOhMyGPT: "OhMyGPT", ChannelTypeCustom: "Custom", ChannelTypeAILS: "AILS", ChannelTypeAIProxy: "AIProxy", ChannelTypePaLM: "PaLM", ChannelTypeAPI2GPT: "API2GPT", ChannelTypeAIGC2D: "AIGC2D", ChannelTypeAnthropic: "Anthropic", ChannelTypeBaidu: "Baidu", ChannelTypeZhipu: "Zhipu", ChannelTypeAli: "Ali", ChannelTypeXunfei: "Xunfei", ChannelType360: "360", ChannelTypeOpenRouter: "OpenRouter", ChannelTypeAIProxyLibrary: "AIProxyLibrary", ChannelTypeFastGPT: "FastGPT", ChannelTypeTencent: "Tencent", ChannelTypeGemini: "Gemini", ChannelTypeMoonshot: "Moonshot", ChannelTypeZhipu_v4: "ZhipuV4", ChannelTypePerplexity: "Perplexity", ChannelTypeLingYiWanWu: "LingYiWanWu", ChannelTypeAws: "AWS", ChannelTypeCohere: "Cohere", ChannelTypeMiniMax: "MiniMax", ChannelTypeSunoAPI: "SunoAPI", ChannelTypeDify: "Dify", ChannelTypeJina: "Jina", ChannelCloudflare: "Cloudflare", ChannelTypeSiliconFlow: "SiliconFlow", ChannelTypeVertexAi: "VertexAI", ChannelTypeMistral: "Mistral", ChannelTypeDeepSeek: "DeepSeek", ChannelTypeMokaAI: "MokaAI", ChannelTypeVolcEngine: "VolcEngine", ChannelTypeBaiduV2: "BaiduV2", ChannelTypeXinference: "Xinference", ChannelTypeXai: "xAI", ChannelTypeCoze: "Coze", ChannelTypeKling: "Kling", ChannelTypeJimeng: "Jimeng", ChannelTypeVidu: "Vidu", ChannelTypeSubmodel: "Submodel", ChannelTypeDoubaoVideo: "DoubaoVideo", ChannelTypeSora: "Sora", ChannelTypeReplicate: "Replicate", ChannelTypeCodex: "ChatGPT Subscription (Codex)", ChannelTypeAdvancedCustom: "Advanced Custom", ChannelTypeSub2API: "Sub2API", ChannelTypeNewAPI: "New API", ChannelTypeTaskPlugin: "Task Plugin", }
var CountToken bool
var DefaultWaffoPayMethods = []WaffoPayMethod{
{Name: "Card", Icon: "/pay-card.png", PayMethodType: "CREDITCARD,DEBITCARD", PayMethodName: ""},
{Name: "Apple Pay", Icon: "/pay-apple.png", PayMethodType: "APPLEPAY", PayMethodName: "APPLEPAY"},
{Name: "Google Pay", Icon: "/pay-google.png", PayMethodType: "GOOGLEPAY", PayMethodName: "GOOGLEPAY"},
}
DefaultWaffoPayMethods is the default list of supported payment methods.
var DifyDebug bool
var ErrorLogEnabled bool
var ForceStreamOption bool
var GenerateDefaultToken bool
var GetMediaToken bool
var GetMediaTokenNotStream bool
var MaxFileDownloadMB int
var MaxRequestBodyMB int
var MidjourneyModel2Action = map[string]string{ "mj_imagine": MjActionImagine, "mj_describe": MjActionDescribe, "mj_blend": MjActionBlend, "mj_upscale": MjActionUpscale, "mj_variation": MjActionVariation, "mj_reroll": MjActionReRoll, "mj_modal": MjActionModal, "mj_inpaint": MjActionInPaint, "mj_zoom": MjActionZoom, "mj_custom_zoom": MjActionCustomZoom, "mj_shorten": MjActionShorten, "mj_high_variation": MjActionHighVariation, "mj_low_variation": MjActionLowVariation, "mj_pan": MjActionPan, "swap_face": MjActionSwapFace, "mj_upload": MjActionUpload, "mj_video": MjActionVideo, "mj_edits": MjActionEdits, }
var NotificationLimitDurationMinute int
var NotifyLimitCount int
var Setup = false
var StreamScannerMaxBufferMB int
var StreamingTimeout int
var TaskPluginEnabled = true
TaskPluginEnabled is the master switch for the whole task-plugin system. When disabled, factory and override plugins both stop serving.
var TaskPluginOverrideEnabled = true
TaskPluginOverrideEnabled controls whether the database override layer is active. When disabled, uploaded plugins are ignored and factory plugins are used instead; the factory layer is unaffected.
var TaskPluginProtocolHeartbeatSeconds int
var TaskPluginProtocolTickJitterMilliseconds int
var TaskPluginProtocolTickMilliseconds int
var TaskPluginProtocolTimeoutSeconds int
var TaskPricePatches []string
temporary variable for sora patch, will be removed in future
var TaskQueryLimit int
var TaskTimeoutMinutes int
var TrustedRedirectDomains []string
TrustedRedirectDomains is a list of trusted domains for redirect URL validation. Domains support subdomain matching (e.g., "example.com" matches "sub.example.com").
var UpdateTask bool
Functions ¶
func GetChannelBaseURL ¶
func GetChannelTypeName ¶
func NormalizeTaskAction ¶
NormalizeTaskAction maps persisted legacy action names to the canonical task action vocabulary. Unknown platform-specific actions pass through unchanged.
Types ¶
type ChannelSpecialBase ¶
type ContextKey ¶
type ContextKey string
const ( ContextKeyTokenCountMeta ContextKey = "token_count_meta" ContextKeyPromptTokens ContextKey = "prompt_tokens" ContextKeyEstimatedTokens ContextKey = "estimated_tokens" ContextKeyOriginalModel ContextKey = "original_model" ContextKeyRequestStartTime ContextKey = "request_start_time" /* token related keys */ ContextKeyTokenUnlimited ContextKey = "token_unlimited_quota" ContextKeyTokenKey ContextKey = "token_key" ContextKeyTokenId ContextKey = "token_id" ContextKeyTokenGroup ContextKey = "token_group" ContextKeyOriginTasks ContextKey = "origin_tasks" ContextKeyChannelConstraints ContextKey = "channel_constraints" ContextKeyTokenModelLimitEnabled ContextKey = "token_model_limit_enabled" ContextKeyTokenModelLimit ContextKey = "token_model_limit" ContextKeyTokenCrossGroupRetry ContextKey = "token_cross_group_retry" ContextKeyTokenAutoGroups ContextKey = "token_auto_groups" /* channel related keys */ ContextKeyChannelId ContextKey = "channel_id" ContextKeyChannelName ContextKey = "channel_name" ContextKeyChannelCreateTime ContextKey = "channel_create_time" ContextKeyChannelBaseUrl ContextKey = "base_url" ContextKeyChannelType ContextKey = "channel_type" ContextKeyChannelSetting ContextKey = "channel_setting" ContextKeyChannelOtherSetting ContextKey = "channel_other_setting" ContextKeyChannelParamOverride ContextKey = "param_override" ContextKeyChannelHeaderOverride ContextKey = "header_override" ContextKeyChannelOrganization ContextKey = "channel_organization" ContextKeyChannelAutoBan ContextKey = "auto_ban" ContextKeyChannelModelMapping ContextKey = "model_mapping" ContextKeyChannelStatusCodeMapping ContextKey = "status_code_mapping" ContextKeyChannelIsMultiKey ContextKey = "channel_is_multi_key" ContextKeyChannelMultiKeyIndex ContextKey = "channel_multi_key_index" ContextKeyChannelKey ContextKey = "channel_key" ContextKeyAutoGroup ContextKey = "auto_group" ContextKeyAutoGroupIndex ContextKey = "auto_group_index" ContextKeyAutoGroupRetryIndex ContextKey = "auto_group_retry_index" /* user related keys */ ContextKeyUserId ContextKey = "id" ContextKeyUserSetting ContextKey = "user_setting" ContextKeyUserQuota ContextKey = "user_quota" ContextKeyUserStatus ContextKey = "user_status" ContextKeyUserEmail ContextKey = "user_email" ContextKeyUserGroup ContextKey = "user_group" ContextKeyUsingGroup ContextKey = "group" ContextKeyUserName ContextKey = "username" ContextKeyLocalCountTokens ContextKey = "local_count_tokens" ContextKeySystemPromptOverride ContextKey = "system_prompt_override" // ContextKeyFileSourcesToCleanup stores file sources that need cleanup when request ends ContextKeyFileSourcesToCleanup ContextKey = "file_sources_to_cleanup" // ContextKeyAdminRejectReason stores an admin-only reject/block reason extracted from upstream responses. // It is not returned to end users, but can be persisted into consume/error logs for debugging. ContextKeyAdminRejectReason ContextKey = "admin_reject_reason" // ContextKeyLanguage stores the user's language preference for i18n ContextKeyLanguage ContextKey = "language" ContextKeyIsStream ContextKey = "is_stream" // ContextKeyAuditLogged marks that the current request has already recorded // a manage/operation audit log inside the handler. When set, the admin-audit // fallback in authHelper (finishAdminAudit) skips its record to avoid // duplicate entries. ContextKeyAuditLogged ContextKey = "audit_logged" )
type EndpointType ¶
type EndpointType = types.EndpointType
EndpointType moved to types with the conversion kit; aliases keep host code compiling unchanged.
type MultiKeyMode ¶
type MultiKeyMode string
const ( MultiKeyModeRandom MultiKeyMode = "random" // 随机 MultiKeyModePolling MultiKeyMode = "polling" // 轮询 )
type TaskPlatform ¶
type TaskPlatform string
const ( TaskPlatformSuno TaskPlatform = "suno" TaskPlatformMidjourney = "mj" )
type WaffoPayMethod ¶ added in v0.11.7
type WaffoPayMethod struct {
Name string `json:"name"` // Frontend display name
Icon string `json:"icon"` // Frontend icon identifier: credit-card, apple, google
PayMethodType string `json:"payMethodType"` // Waffo API PayMethodType, can be comma-separated
PayMethodName string `json:"payMethodName"` // Waffo API PayMethodName, empty means auto-select by Waffo checkout
}
WaffoPayMethod defines the display and API parameter mapping for Waffo payment methods.