Documentation
¶
Index ¶
Constants ¶
View Source
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 APITypeDummy // this one is only for count, do not add any channel after this )
View Source
const ( UserGroupKeyFmt = "user_group:%d" UserQuotaKeyFmt = "user_quota:%d" UserEnabledKeyFmt = "user_enabled:%d" UserUsernameKeyFmt = "user_name:%d" )
Cache keys
View Source
const ( TokenFiledRemainQuota = "RemainQuota" TokenFieldGroup = "Group" )
View Source
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 ChannelTypeDummy // this one is only for count, do not add any channel after this )
View Source
const ( MjErrorUnknown = 5 MjRequestError = 4 )
View Source
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" )
View Source
const ( SunoActionMusic = "MUSIC" SunoActionLyrics = "LYRICS" TaskActionGenerate = "generate" TaskActionTextGenerate = "textGenerate" TaskActionFirstTailGenerate = "firstTailGenerate" TaskActionReferenceGenerate = "referenceGenerate" TaskActionRemix = "remixGenerate" )
Variables ¶
View Source
var ( FinishReasonStop = "stop" FinishReasonToolCalls = "tool_calls" FinishReasonLength = "length" FinishReasonFunctionCall = "function_call" FinishReasonContentFilter = "content_filter" )
View Source
var AzureDefaultAPIVersion string
View Source
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",
}
View Source
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",
},
}
View Source
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: "Codex", }
View Source
var CountToken bool
View Source
var DifyDebug bool
View Source
var ErrorLogEnabled bool
View Source
var ForceStreamOption bool
View Source
var GenerateDefaultToken bool
View Source
var GetMediaToken bool
View Source
var GetMediaTokenNotStream bool
View Source
var MaxFileDownloadMB int
View Source
var MaxRequestBodyMB int
View Source
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, }
View Source
var NotificationLimitDurationMinute int
View Source
var NotifyLimitCount int
View Source
var Setup = false
View Source
var StreamScannerMaxBufferMB int
View Source
var StreamingTimeout int
View Source
var SunoModel2Action = map[string]string{ "suno_music": SunoActionMusic, "suno_lyrics": SunoActionLyrics, }
View Source
var TaskPricePatches []string
temporary variable for sora patch, will be removed in future
View Source
var TaskQueryLimit int
View Source
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").
View Source
var UpdateTask bool
Functions ¶
func GetChannelTypeName ¶
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" ContextKeyTokenSpecificChannelId ContextKey = "specific_channel_id" ContextKeyTokenModelLimitEnabled ContextKey = "token_model_limit_enabled" ContextKeyTokenModelLimit ContextKey = "token_model_limit" ContextKeyTokenCrossGroupRetry ContextKey = "token_cross_group_retry" /* 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" )
type EndpointType ¶
type EndpointType string
const ( EndpointTypeOpenAI EndpointType = "openai" EndpointTypeOpenAIResponse EndpointType = "openai-response" EndpointTypeOpenAIResponseCompact EndpointType = "openai-response-compact" EndpointTypeAnthropic EndpointType = "anthropic" EndpointTypeGemini EndpointType = "gemini" EndpointTypeJinaRerank EndpointType = "jina-rerank" EndpointTypeImageGeneration EndpointType = "image-generation" EndpointTypeEmbeddings EndpointType = "embeddings" EndpointTypeOpenAIVideo EndpointType = "openai-video" )
type MultiKeyMode ¶
type MultiKeyMode string
const ( MultiKeyModeRandom MultiKeyMode = "random" // 随机 MultiKeyModePolling MultiKeyMode = "polling" // 轮询 )
type TaskPlatform ¶
type TaskPlatform string
const ( TaskPlatformSuno TaskPlatform = "suno" TaskPlatformMidjourney = "mj" )
Click to show internal directories.
Click to hide internal directories.