Documentation
¶
Index ¶
- Constants
- Variables
- func AddChannel(c *gin.Context)
- func AddChannels(c *gin.Context)
- func AddGroupToken(c *gin.Context)
- func AddOneAPIChannel(ch OneAPIChannel) error
- func AutoTestBannedModels()
- func BuiltinModels(c *gin.Context)
- func ChannelBuiltinModels(c *gin.Context)
- func ChannelBuiltinModelsByType(c *gin.Context)
- func ChannelDefaultModelsAndMapping(c *gin.Context)
- func ChannelDefaultModelsAndMappingByType(c *gin.Context)
- func ChannelEnabledModels(c *gin.Context)
- func ChannelEnabledModelsByType(c *gin.Context)
- func ChannelTypeMetas(c *gin.Context)
- func ChannelTypeNames(c *gin.Context)
- func ClearAllModelErrors(c *gin.Context)
- func ClearChannelAllModelErrors(c *gin.Context)
- func ClearChannelModelErrors(c *gin.Context)
- func CreateGroup(c *gin.Context)
- func DeleteChannel(c *gin.Context)
- func DeleteChannels(c *gin.Context)
- func DeleteGroup(c *gin.Context)
- func DeleteGroupToken(c *gin.Context)
- func DeleteGroupTokens(c *gin.Context)
- func DeleteGroups(c *gin.Context)
- func DeleteHistoryLogs(c *gin.Context)
- func DeleteModelConfig(c *gin.Context)
- func DeleteModelConfigs(c *gin.Context)
- func DeleteToken(c *gin.Context)
- func DeleteTokens(c *gin.Context)
- func EnabledModels(c *gin.Context)
- func GetAllBannedModelChannels(c *gin.Context)
- func GetAllChannelModelErrorRates(c *gin.Context)
- func GetAllChannels(c *gin.Context)
- func GetAllModelConfigs(c *gin.Context)
- func GetChannel(c *gin.Context)
- func GetChannelModelErrorRates(c *gin.Context)
- func GetChannels(c *gin.Context)
- func GetDashboard(c *gin.Context)
- func GetGroup(c *gin.Context)
- func GetGroupDashboard(c *gin.Context)
- func GetGroupDashboardModels(c *gin.Context)
- func GetGroupLogDetail(c *gin.Context)
- func GetGroupLogs(c *gin.Context)
- func GetGroupModelCostRank(c *gin.Context)
- func GetGroupToken(c *gin.Context)
- func GetGroupTokens(c *gin.Context)
- func GetGroupUsedModels(c *gin.Context)
- func GetGroupUsedTokenNames(c *gin.Context)
- func GetGroups(c *gin.Context)
- func GetLogDetail(c *gin.Context)
- func GetLogs(c *gin.Context)
- func GetModelConfig(c *gin.Context)
- func GetModelConfigs(c *gin.Context)
- func GetModelConfigsByModelsContains(c *gin.Context)
- func GetModelCostRank(c *gin.Context)
- func GetModelsErrorRate(c *gin.Context)
- func GetOption(c *gin.Context)
- func GetOptions(c *gin.Context)
- func GetRandomChannel(c *dbmodel.ModelCaches, model string, errorRates map[int64]float64, ...) (*dbmodel.Channel, error)
- func GetStatus(c *gin.Context)
- func GetSubscription(c *gin.Context)
- func GetToken(c *gin.Context)
- func GetTokens(c *gin.Context)
- func GetUsage(c *gin.Context)
- func GetUsedModels(c *gin.Context)
- func ImportChannelFromOneAPI(c *gin.Context)
- func ListModels(c *gin.Context)
- func NewRelay(mode relaymode.Mode) func(c *gin.Context)
- func RelayHelper(meta *meta.Meta, c *gin.Context, relayController RelayController) (*controller.HandleResult, bool)
- func RelayNotImplemented(c *gin.Context)
- func RetrieveModel(c *gin.Context)
- func SaveModelConfig(c *gin.Context)
- func SaveModelConfigs(c *gin.Context)
- func SearchChannels(c *gin.Context)
- func SearchConsumeError(c *gin.Context)
- func SearchGroupLogs(c *gin.Context)
- func SearchGroupTokens(c *gin.Context)
- func SearchGroups(c *gin.Context)
- func SearchLogs(c *gin.Context)
- func SearchModelConfigs(c *gin.Context)
- func SearchTokens(c *gin.Context)
- func SortBuiltinModelConfigsFunc(i, j *BuiltinModelConfig) int
- func TestAllChannels(c *gin.Context)
- func TestChannel(c *gin.Context)
- func TestChannelModels(c *gin.Context)
- func UpdateAllChannelsBalance(c *gin.Context)
- func UpdateChannel(c *gin.Context)
- func UpdateChannelBalance(c *gin.Context)
- func UpdateChannelStatus(c *gin.Context)
- func UpdateChannelsBalance(frequency time.Duration)
- func UpdateGroup(c *gin.Context)
- func UpdateGroupRPM(c *gin.Context)
- func UpdateGroupRPMRatio(c *gin.Context)
- func UpdateGroupStatus(c *gin.Context)
- func UpdateGroupTPM(c *gin.Context)
- func UpdateGroupTPMRatio(c *gin.Context)
- func UpdateGroupToken(c *gin.Context)
- func UpdateGroupTokenName(c *gin.Context)
- func UpdateGroupTokenStatus(c *gin.Context)
- func UpdateOption(c *gin.Context)
- func UpdateOptions(c *gin.Context)
- func UpdateToken(c *gin.Context)
- func UpdateTokenName(c *gin.Context)
- func UpdateTokenStatus(c *gin.Context)
- type AddChannelRequest
- type AddTokenRequest
- type BuiltinModelConfig
- type ChannelConfig
- type CreateGroupRequest
- type GetModelConfigsByModelsContainsRequest
- type GroupResponse
- type ImportChannelFromOneAPIRequest
- type OneAPIChannel
- type OpenAIModelPermission
- type OpenAIModels
- type RelayController
- type SaveModelConfigsRequest
- type StatusData
- type TokenResponse
- type UpdateChannelStatusRequest
- type UpdateGroupRPMRatioRequest
- type UpdateGroupRPMRequest
- type UpdateGroupStatusRequest
- type UpdateGroupTPMRatioRequest
- type UpdateGroupTPMRequest
- type UpdateTokenNameRequest
- type UpdateTokenStatusRequest
Constants ¶
View Source
const ( OneAPIOpenAI = iota + 1 OneAPIAPI2D OneAPIAzure OneAPICloseAI OneAPIOpenAISB OneAPIOpenAIMax OneAPIOhMyGPT OneAPICustom OneAPIAils OneAPIAIProxy OneAPIPaLM OneAPIAPI2GPT OneAPIAIGC2D OneAPIAnthropic OneAPIBaidu OneAPIZhipu OneAPIAli OneAPIXunfei OneAPIAI360 OneAPIOpenRouter OneAPIAIProxyLibrary OneAPIFastGPT OneAPITencent OneAPIGemini OneAPIMoonshot OneAPIBaichuan OneAPIMinimax OneAPIMistral OneAPIGroq OneAPIOllama OneAPILingYiWanWu OneAPIStepFun OneAPIAwsClaude OneAPICoze OneAPICohere OneAPIDeepSeek OneAPICloudflare OneAPIDeepL OneAPITogetherAI OneAPIDoubao OneAPINovita OneAPIVertextAI OneAPIProxy OneAPISiliconFlow OneAPIXAI OneAPIReplicate OneAPIBaiduV2 OneAPIXunfeiV2 OneAPIAliBailian OneAPIOpenAICompatible OneAPIGeminiOpenAICompatible )
https://github.com/songquanpeng/one-api/blob/main/relay/channeltype/define.go
View Source
const (
AIProxyChannelHeader = "Aiproxy-Channel"
)
Variables ¶
View Source
var ( ErrChannelsNotFound = errors.New("channels not found") ErrChannelsExhausted = errors.New("channels exhausted") )
View Source
var OneAPIChannelType2AIProxyMap = map[int]int{ OneAPIOpenAI: 1, OneAPIAzure: 3, OneAPIAnthropic: 14, OneAPIBaidu: 15, OneAPIZhipu: 16, OneAPIAli: 17, OneAPIAI360: 19, OneAPITencent: 23, OneAPIGemini: 24, OneAPIMoonshot: 25, OneAPIBaichuan: 26, OneAPIMinimax: 27, OneAPIMistral: 28, OneAPIGroq: 29, OneAPIOllama: 30, OneAPILingYiWanWu: 31, OneAPIStepFun: 32, OneAPIAwsClaude: 33, OneAPICoze: 34, OneAPICohere: 35, OneAPIDeepSeek: 36, OneAPICloudflare: 37, OneAPIDoubao: 40, OneAPINovita: 41, OneAPIVertextAI: 42, OneAPISiliconFlow: 43, OneAPIBaiduV2: 13, OneAPIXunfeiV2: 18, OneAPIAliBailian: 17, OneAPIGeminiOpenAICompatible: 12, OneAPIXAI: 45, }
Functions ¶
func AddChannel ¶
func AddChannels ¶
func AddGroupToken ¶
func AddOneAPIChannel ¶
func AddOneAPIChannel(ch OneAPIChannel) error
func AutoTestBannedModels ¶
func AutoTestBannedModels()
func BuiltinModels ¶
func ChannelBuiltinModels ¶
func ChannelEnabledModels ¶
func ChannelTypeMetas ¶
func ChannelTypeNames ¶
func ClearAllModelErrors ¶
func ClearChannelModelErrors ¶
func CreateGroup ¶
func DeleteChannel ¶
func DeleteChannels ¶
func DeleteGroup ¶
func DeleteGroupToken ¶
func DeleteGroupTokens ¶
func DeleteGroups ¶
func DeleteHistoryLogs ¶
func DeleteModelConfig ¶
func DeleteModelConfigs ¶
func DeleteTokens ¶
func EnabledModels ¶
func GetAllChannels ¶
func GetAllModelConfigs ¶
func GetChannel ¶
func GetChannels ¶
func GetDashboard ¶
func GetGroupDashboard ¶
func GetGroupDashboardModels ¶
func GetGroupLogDetail ¶
func GetGroupLogs ¶
func GetGroupModelCostRank ¶
func GetGroupToken ¶
func GetGroupTokens ¶
func GetGroupUsedModels ¶
func GetGroupUsedTokenNames ¶
func GetLogDetail ¶
func GetModelConfig ¶
func GetModelConfigs ¶
func GetModelCostRank ¶
func GetModelsErrorRate ¶
func GetOptions ¶
func GetRandomChannel ¶
func GetUsedModels ¶
func ImportChannelFromOneAPI ¶
func ListModels ¶
func RelayHelper ¶
func RelayHelper(meta *meta.Meta, c *gin.Context, relayController RelayController) (*controller.HandleResult, bool)
func RelayNotImplemented ¶
func RetrieveModel ¶
func SaveModelConfig ¶
func SaveModelConfigs ¶
func SearchChannels ¶
func SearchConsumeError ¶
func SearchGroupLogs ¶
func SearchGroupTokens ¶
func SearchGroups ¶
func SearchLogs ¶
func SearchModelConfigs ¶
func SearchTokens ¶
func SortBuiltinModelConfigsFunc ¶
func SortBuiltinModelConfigsFunc(i, j *BuiltinModelConfig) int
func TestAllChannels ¶
func TestChannel ¶
func TestChannelModels ¶
func UpdateChannel ¶
func UpdateChannelBalance ¶
func UpdateChannelStatus ¶
func UpdateChannelsBalance ¶
func UpdateGroup ¶
func UpdateGroupRPM ¶
func UpdateGroupRPMRatio ¶
func UpdateGroupStatus ¶
func UpdateGroupTPM ¶
func UpdateGroupTPMRatio ¶
func UpdateGroupToken ¶
func UpdateGroupTokenName ¶
func UpdateGroupTokenStatus ¶
func UpdateOption ¶
func UpdateOptions ¶
func UpdateTokenName ¶
func UpdateTokenStatus ¶
Types ¶
type AddChannelRequest ¶
type AddChannelRequest struct {
ModelMapping map[string]string `json:"model_mapping"`
Config *model.ChannelConfig `json:"config"`
Name string `json:"name"`
Key string `json:"key"`
BaseURL string `json:"base_url"`
Other string `json:"other"`
Models []string `json:"models"`
Type int `json:"type"`
Priority int32 `json:"priority"`
Status int `json:"status"`
}
func (*AddChannelRequest) ToChannel ¶
func (r *AddChannelRequest) ToChannel() (*model.Channel, error)
func (*AddChannelRequest) ToChannels ¶
func (r *AddChannelRequest) ToChannels() ([]*model.Channel, error)
type AddTokenRequest ¶
type AddTokenRequest struct {
Name string `json:"name"`
Subnets []string `json:"subnets"`
Models []string `json:"models"`
ExpiredAt int64 `json:"expiredAt"`
Quota float64 `json:"quota"`
}
func (*AddTokenRequest) ToToken ¶
func (at *AddTokenRequest) ToToken() *model.Token
type BuiltinModelConfig ¶
type BuiltinModelConfig model.ModelConfig
func (*BuiltinModelConfig) MarshalJSON ¶
func (c *BuiltinModelConfig) MarshalJSON() ([]byte, error)
type ChannelConfig ¶
type ChannelConfig struct {
Region string `json:"region,omitempty"`
SK string `json:"sk,omitempty"`
AK string `json:"ak,omitempty"`
UserID string `json:"user_id,omitempty"`
APIVersion string `json:"api_version,omitempty"`
LibraryID string `json:"library_id,omitempty"`
VertexAIProjectID string `json:"vertex_ai_project_id,omitempty"`
VertexAIADC string `json:"vertex_ai_adc,omitempty"`
}
type CreateGroupRequest ¶
type GetModelConfigsByModelsContainsRequest ¶
type GetModelConfigsByModelsContainsRequest struct {
Models []string `json:"models"`
}
type GroupResponse ¶
func (*GroupResponse) MarshalJSON ¶
func (g *GroupResponse) MarshalJSON() ([]byte, error)
type ImportChannelFromOneAPIRequest ¶
type ImportChannelFromOneAPIRequest struct {
DSN string `json:"dsn"`
}
type OneAPIChannel ¶
type OneAPIChannel struct {
Type int `gorm:"default:0" json:"type"`
Key string `gorm:"type:text" json:"key"`
Status int `gorm:"default:1" json:"status"`
Name string `gorm:"index" json:"name"`
BaseURL string `gorm:"column:base_url;default:''"`
Models string `json:"models"`
ModelMapping map[string]string `gorm:"type:varchar(1024);serializer:fastjson"`
Priority int32 `gorm:"bigint;default:0"`
Config ChannelConfig `gorm:"serializer:fastjson"`
}
func (*OneAPIChannel) TableName ¶
func (c *OneAPIChannel) TableName() string
type OpenAIModelPermission ¶
type OpenAIModelPermission struct {
Group *string `json:"group"`
ID string `json:"id"`
Object string `json:"object"`
Organization string `json:"organization"`
Created int `json:"created"`
AllowCreateEngine bool `json:"allow_create_engine"`
AllowSampling bool `json:"allow_sampling"`
AllowLogprobs bool `json:"allow_logprobs"`
AllowSearchIndices bool `json:"allow_search_indices"`
AllowView bool `json:"allow_view"`
AllowFineTuning bool `json:"allow_fine_tuning"`
IsBlocking bool `json:"is_blocking"`
}
type OpenAIModels ¶
type RelayController ¶
type RelayController func(*meta.Meta, *gin.Context) *controller.HandleResult
type SaveModelConfigsRequest ¶
type SaveModelConfigsRequest struct {
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
*model.ModelConfig
}
type StatusData ¶
type StatusData struct {
StartTime int64 `json:"startTime"`
}
type TokenResponse ¶
TokenResponse represents the response structure for token endpoints
func (*TokenResponse) MarshalJSON ¶
func (t *TokenResponse) MarshalJSON() ([]byte, error)
type UpdateChannelStatusRequest ¶
type UpdateChannelStatusRequest struct {
Status int `json:"status"`
}
type UpdateGroupRPMRatioRequest ¶
type UpdateGroupRPMRatioRequest struct {
RPMRatio float64 `json:"rpm_ratio"`
}
type UpdateGroupRPMRequest ¶
type UpdateGroupStatusRequest ¶
type UpdateGroupStatusRequest struct {
Status int `json:"status"`
}
type UpdateGroupTPMRatioRequest ¶
type UpdateGroupTPMRatioRequest struct {
TPMRatio float64 `json:"tpm_ratio"`
}
type UpdateGroupTPMRequest ¶
type UpdateTokenNameRequest ¶
type UpdateTokenNameRequest struct {
Name string `json:"name"`
}
type UpdateTokenStatusRequest ¶
type UpdateTokenStatusRequest struct {
Status int `json:"status"`
}
Click to show internal directories.
Click to hide internal directories.