Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/api_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func ChannelType2APIType(channelType int) (int, bool) {
apiType = constant.APITypeSub2API
case constant.ChannelTypeNewAPI:
apiType = constant.APITypeNewAPI
case constant.ChannelTypeAvalAI:
apiType = constant.APITypeAvalAI
}
if apiType == -1 {
return constant.APITypeOpenAI, false
Expand Down
1 change: 1 addition & 0 deletions constant/api_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ const (
APITypeAdvancedCustom
APITypeSub2API
APITypeNewAPI
APITypeAvalAI
APITypeDummy // this one is only for count, do not add any channel after this
)
3 changes: 3 additions & 0 deletions constant/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
ChannelTypeAdvancedCustom = 58
ChannelTypeSub2API = 59
ChannelTypeNewAPI = 60
ChannelTypeAvalAI = 61
ChannelTypeDummy // this one is only for count, do not add any channel after this

)
Expand Down Expand Up @@ -124,6 +125,7 @@ var ChannelBaseURLs = []string{
"", //58
"", //59
"", //60
"https://api.avalai.ir", //61
}

var ChannelTypeNames = map[int]string{
Expand Down Expand Up @@ -184,6 +186,7 @@ var ChannelTypeNames = map[int]string{
ChannelTypeAdvancedCustom: "Advanced Custom",
ChannelTypeSub2API: "Sub2API",
ChannelTypeNewAPI: "New API",
ChannelTypeAvalAI: "AvalAI",
}

func GetChannelTypeName(channelType int) string {
Expand Down
23 changes: 23 additions & 0 deletions relay/channel/avalai/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package avalai

// https://docs.avalai.ir
// AvalAI is an OpenAI-compatible AI gateway that proxies models from
// OpenAI, Anthropic, Google, DeepSeek and other providers.
// The full model list can be fetched from upstream /v1/models.

var ModelList = []string{
"gpt-4o",
"gpt-4o-mini",
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",
"o4-mini",
"claude-3-5-sonnet-20241022",
"claude-sonnet-4-20250514",
"gemini-2.0-flash",
"gemini-2.5-pro",
"deepseek-chat",
"deepseek-reasoner",
}

var ChannelName = "avalai"
5 changes: 5 additions & 0 deletions relay/channel/openai/adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/QuantumNous/new-api/logger"
"github.com/QuantumNous/new-api/relay/channel"
"github.com/QuantumNous/new-api/relay/channel/ai360"
"github.com/QuantumNous/new-api/relay/channel/avalai"
"github.com/QuantumNous/new-api/relay/channel/lingyiwanwu"
"github.com/QuantumNous/new-api/relaykit/dto"

Expand Down Expand Up @@ -674,6 +675,8 @@ func (a *Adaptor) GetModelList() []string {
return ai360.ModelList
case constant.ChannelTypeLingYiWanWu:
return lingyiwanwu.ModelList
case constant.ChannelTypeAvalAI:
return avalai.ModelList
//case constant.ChannelTypeMiniMax:
// return minimax.ModelList
case constant.ChannelTypeXinference:
Expand All @@ -691,6 +694,8 @@ func (a *Adaptor) GetChannelName() string {
return ai360.ChannelName
case constant.ChannelTypeLingYiWanWu:
return lingyiwanwu.ChannelName
case constant.ChannelTypeAvalAI:
return avalai.ChannelName
//case constant.ChannelTypeMiniMax:
// return minimax.ChannelName
case constant.ChannelTypeXinference:
Expand Down
1 change: 1 addition & 0 deletions relay/common/relay_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ var streamSupportedChannels = map[int]bool{
constant.ChannelTypeSub2API: true,
constant.ChannelTypeNewAPI: true,
constant.ChannelTypeTencent: true,
constant.ChannelTypeAvalAI: true,
}

func GenRelayInfoWs(c *gin.Context, ws *websocket.Conn) *RelayInfo {
Expand Down
2 changes: 2 additions & 0 deletions relay/relay_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ func GetAdaptor(apiType int) channel.Adaptor {
return &sub2api.Adaptor{}
case constant.APITypeNewAPI:
return &newapi.Adaptor{}
case constant.APITypeAvalAI:
return &openai.Adaptor{}
}
return nil
}
Expand Down
9 changes: 5 additions & 4 deletions web/src/features/channels/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ export const CHANNEL_TYPES = {
58: 'Advanced Custom',
59: 'Sub2API',
60: 'New API',
61: 'AvalAI',
} as const
Comment on lines +84 to 85

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Translate the AvalAI channel label through i18n.

CHANNEL_TYPE_OPTIONS passes CHANNEL_TYPES labels directly to the UI. The new "AvalAI" value is therefore user-facing raw text. Store a translation key and translate it in the rendering component with t().

As per coding guidelines, frontend user-facing text must use i18n and React components must render it through t().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/src/features/channels/constants.ts` around lines 84 - 85, Update the
AvalAI label in CHANNEL_TYPE_OPTIONS to use a translation key instead of raw
user-facing text, then update the component rendering CHANNEL_TYPES options to
pass that key through the existing t() i18n function. Preserve the current
option value and behavior for all other channel types.

Source: Coding guidelines


const CHANNEL_TYPE_DISPLAY_ORDER: number[] = [
1, 14, 33, 24, 43, 3, 41, 48, 60, 58, 42, 34, 20, 4, 40, 27, 25, 17, 26, 15,
46, 23, 18, 45, 31, 35, 49, 19, 47, 37, 38, 39, 11, 8, 57, 59, 22, 21, 44, 2,
5, 36, 50, 51, 52, 53, 54, 55, 56,
1, 14, 33, 24, 43, 3, 41, 48, 60, 58, 42, 34, 20, 61, 4, 40, 27, 25, 17, 26,
15, 46, 23, 18, 45, 31, 35, 49, 19, 47, 37, 38, 39, 11, 8, 57, 59, 22, 21,
44, 2, 5, 36, 50, 51, 52, 53, 54, 55, 56,
]

export const CHANNEL_TYPE_OPTIONS: { value: number; label: string }[] = (() => {
Expand Down Expand Up @@ -389,7 +390,7 @@ export const FIELD_DESCRIPTIONS = {

export const MODEL_FETCHABLE_TYPES = new Set([
1, 4, 14, 17, 20, 23, 24, 25, 26, 27, 31, 34, 35, 40, 42, 43, 47, 48, 57, 58,
59, 60,
59, 60, 61,
])

export const TYPE_TO_KEY_PROMPT: Record<number, string> = {
Expand Down
1 change: 1 addition & 0 deletions web/src/features/channels/lib/channel-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export function getChannelTypeIcon(type: number): string {
53: 'OpenAI', // Submodel

// AI Proxy services
61: 'OpenAI', // AvalAI
10: 'OpenAI', // AI Proxy
21: 'OpenAI', // AI Proxy Library
12: 'OpenAI', // API2GPT
Expand Down