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 @@ -75,6 +75,8 @@ func ChannelType2APIType(channelType int) (int, bool) {
apiType = constant.APITypeReplicate
case constant.ChannelTypeCodex:
apiType = constant.APITypeCodex
case constant.ChannelTypeAGIone:
apiType = constant.APITypeAGIone
}
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 @@ -36,5 +36,6 @@ const (
APITypeMiniMax
APITypeReplicate
APITypeCodex
APITypeAGIone
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 @@ -55,6 +55,7 @@ const (
ChannelTypeSora = 55
ChannelTypeReplicate = 56
ChannelTypeCodex = 57
ChannelTypeAGIone = 58
ChannelTypeDummy // this one is only for count, do not add any channel after this

)
Expand Down Expand Up @@ -118,6 +119,7 @@ var ChannelBaseURLs = []string{
"https://api.openai.com", //55
"https://api.replicate.com", //56
"https://chatgpt.com", //57
"https://agione.pro/hyperone/xapi/api/v1", //58
}

var ChannelTypeNames = map[int]string{
Expand Down Expand Up @@ -175,6 +177,7 @@ var ChannelTypeNames = map[int]string{
ChannelTypeSora: "Sora",
ChannelTypeReplicate: "Replicate",
ChannelTypeCodex: "Codex",
ChannelTypeAGIone: "AGIone",
}

func GetChannelTypeName(channelType int) string {
Expand Down
2 changes: 2 additions & 0 deletions controller/channel_upstream_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ func fetchChannelUpstreamModelIDs(channel *model.Channel) ([]string, error) {
} else {
url = fmt.Sprintf("%s/v1/models", baseURL)
}
case constant.ChannelTypeAGIone:
url = fmt.Sprintf("%s/models", strings.TrimSuffix(baseURL, "/v1"))
default:
url = fmt.Sprintf("%s/v1/models", baseURL)
}
Expand Down
43 changes: 43 additions & 0 deletions relay/channel/agione/adaptor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package agione

import (
"fmt"
"strings"

channelconstant "github.com/QuantumNous/new-api/constant"
"github.com/QuantumNous/new-api/relay/channel/openai"
relaycommon "github.com/QuantumNous/new-api/relay/common"
relayconstant "github.com/QuantumNous/new-api/relay/constant"
"github.com/QuantumNous/new-api/types"
)

type Adaptor struct {
openai.Adaptor
}

func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
baseURL := info.ChannelBaseUrl
if baseURL == "" {
baseURL = channelconstant.ChannelBaseURLs[channelconstant.ChannelTypeAGIone]
}

if (info.RelayFormat == types.RelayFormatClaude || info.RelayFormat == types.RelayFormatGemini) &&
info.RelayMode != relayconstant.RelayModeResponses &&
info.RelayMode != relayconstant.RelayModeResponsesCompact {
return fmt.Sprintf("%s/chat/completions", baseURL), nil
}

requestPath := info.RequestURLPath
if requestPath == "" {
return baseURL, nil
}
return fmt.Sprintf("%s%s", baseURL, strings.TrimPrefix(requestPath, "/v1")), nil
}

func (a *Adaptor) GetModelList() []string {
return ModelList
}

func (a *Adaptor) GetChannelName() string {
return ChannelName
}
28 changes: 28 additions & 0 deletions relay/channel/agione/adaptor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package agione

import (
"testing"

channelconstant "github.com/QuantumNous/new-api/constant"
relaycommon "github.com/QuantumNous/new-api/relay/common"
)

func TestGetRequestURLTrimsOpenAIVersionPrefix(t *testing.T) {
adaptor := &Adaptor{}
info := &relaycommon.RelayInfo{
ChannelMeta: &relaycommon.ChannelMeta{
ChannelType: channelconstant.ChannelTypeAGIone,
ChannelBaseUrl: channelconstant.ChannelBaseURLs[channelconstant.ChannelTypeAGIone],
},
RequestURLPath: "/v1/chat/completions",
}

got, err := adaptor.GetRequestURL(info)
if err != nil {
t.Fatalf("GetRequestURL returned error: %v", err)
}
want := "https://agione.pro/hyperone/xapi/api/v1/chat/completions"
if got != want {
t.Fatalf("GetRequestURL() = %q, want %q", got, want)
}
}
9 changes: 9 additions & 0 deletions relay/channel/agione/constant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package agione

var ModelList = []string{
"openai/GPT-5.5/c6fbe",
"anthropic/Claude-opus-4.7/a4d5d",
"deepseek/deepseek-v3.2/0000n",
}

var ChannelName = "agione"
1 change: 1 addition & 0 deletions relay/common/relay_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ var streamSupportedChannels = map[int]bool{
constant.ChannelTypeMoonshot: true,
constant.ChannelTypeMiniMax: true,
constant.ChannelTypeSiliconFlow: true,
constant.ChannelTypeAGIone: true,
}

func GenRelayInfoWs(c *gin.Context, ws *websocket.Conn) *RelayInfo {
Expand Down
3 changes: 3 additions & 0 deletions relay/relay_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/QuantumNous/new-api/constant"
"github.com/QuantumNous/new-api/relay/channel"
"github.com/QuantumNous/new-api/relay/channel/agione"
"github.com/QuantumNous/new-api/relay/channel/ali"
"github.com/QuantumNous/new-api/relay/channel/aws"
"github.com/QuantumNous/new-api/relay/channel/baidu"
Expand Down Expand Up @@ -120,6 +121,8 @@ func GetAdaptor(apiType int) channel.Adaptor {
return &replicate.Adaptor{}
case constant.APITypeCodex:
return &codex.Adaptor{}
case constant.APITypeAGIone:
return &agione.Adaptor{}
}
return nil
}
Expand Down
7 changes: 6 additions & 1 deletion web/classic/src/constants/channel.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,16 @@ export const CHANNEL_OPTIONS = [
color: 'blue',
label: 'Codex (OpenAI OAuth)',
},
{
value: 58,
color: 'green',
label: 'AGIone',
},
];

// Channel types that support upstream model list fetching in UI.
export const MODEL_FETCHABLE_CHANNEL_TYPES = new Set([
1, 4, 14, 34, 17, 26, 27, 24, 47, 25, 20, 23, 31, 40, 42, 48, 43,
1, 4, 14, 34, 17, 26, 27, 24, 47, 25, 20, 23, 31, 40, 42, 48, 43, 58,
]);

export const MODEL_TABLE_PAGE_SIZE = 10;
4 changes: 3 additions & 1 deletion web/default/src/features/channels/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ export const CHANNEL_TYPES = {
55: 'Sora',
56: 'Replicate',
57: 'Codex',
58: 'AGIone',
} as const

const CHANNEL_TYPE_DISPLAY_ORDER: number[] = [
1, 14, 33, 24, 43, 3, 41, 48, 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, 22, 21, 44, 2, 5, 36, 50,
18, 45, 31, 35, 49, 19, 47, 37, 38, 39, 11, 58, 8, 57, 22, 21, 44, 2, 5, 36, 50,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
51, 52, 53, 54, 55, 56,
]

Expand Down Expand Up @@ -377,6 +378,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,
58,
])

export const TYPE_TO_KEY_PROMPT: Record<number, string> = {
Expand Down
12 changes: 12 additions & 0 deletions web/default/src/features/channels/lib/channel-type-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ export const CHANNEL_TYPE_CONFIGS: Record<number, ChannelTypeConfig> = {
models: 'Use model IDs from OpenRouter',
},
},
58: {
id: 58,
name: CHANNEL_TYPES[58],
icon: 'openai',
defaultBaseUrl: 'https://agione.pro/hyperone/xapi/api/v1',
hints: {
key: 'AGIone Auth Token',
models:
'openai/GPT-5.5/c6fbe,anthropic/Claude-opus-4.7/a4d5d,deepseek/deepseek-v3.2/0000n',
baseUrl: 'Default: https://agione.pro/hyperone/xapi/api/v1',
},
},
56: {
id: 56,
name: CHANNEL_TYPES[56],
Expand Down