@@ -135,7 +135,7 @@ func providerCoolingDisabledForAuth(auth *Auth, cfg *internalconfig.Config) bool
135135 providerKey = strings .TrimSpace (auth .Attributes ["provider_key" ])
136136 compatName = strings .TrimSpace (auth .Attributes ["compat_name" ])
137137 }
138- if providerKey == "" && compatName == "" && provider != "openai-compatibility" {
138+ if providerKey == "" && compatName == "" && ! util . IsOpenAICompatibleProvider ( provider ) {
139139 return false
140140 }
141141 if providerKey == "" {
@@ -1011,13 +1011,13 @@ func isOpenAICompatAPIKeyAuth(auth *Auth) bool {
10111011 if ! isAPIKeyAuth (auth ) {
10121012 return false
10131013 }
1014- if strings . EqualFold ( strings . TrimSpace ( auth .Provider ), "openai-compatibility" ) {
1014+ if util . IsOpenAICompatibleProvider ( auth .Provider ) {
10151015 return true
10161016 }
10171017 if auth .Attributes == nil {
10181018 return false
10191019 }
1020- return strings . TrimSpace (auth . Attributes [ "compat_name" ] ) != ""
1020+ return authAttribute (auth , "compat_name" ) != ""
10211021}
10221022
10231023func openAICompatProviderKey (auth * Auth ) string {
@@ -1300,7 +1300,7 @@ func (m *Manager) resolveAPIKeyModelAliasWithResult(auth *Auth, requestedModel s
13001300 providerKey = strings .TrimSpace (auth .Attributes ["provider_key" ])
13011301 compatName = strings .TrimSpace (auth .Attributes ["compat_name" ])
13021302 }
1303- if compatName != "" || strings . EqualFold ( strings . TrimSpace ( auth .Provider ), "openai-compatibility" ) {
1303+ if compatName != "" || util . IsOpenAICompatibleProvider ( auth .Provider ) {
13041304 if entry := resolveOpenAICompatConfig (cfg , providerKey , compatName , auth .Provider ); entry != nil {
13051305 models = asModelAliasEntries (entry .Models )
13061306 }
@@ -1979,7 +1979,7 @@ func (m *Manager) rebuildAPIKeyModelAliasLocked(cfg *internalconfig.Config) {
19791979 providerKey = strings .TrimSpace (auth .Attributes ["provider_key" ])
19801980 compatName = strings .TrimSpace (auth .Attributes ["compat_name" ])
19811981 }
1982- if compatName != "" || strings . EqualFold ( strings . TrimSpace ( auth .Provider ), "openai-compatibility" ) {
1982+ if compatName != "" || util . IsOpenAICompatibleProvider ( auth .Provider ) {
19831983 if entry := resolveOpenAICompatConfig (cfg , providerKey , compatName , auth .Provider ); entry != nil {
19841984 compileAPIKeyModelAliasForModels (byAlias , entry .Models )
19851985 }
@@ -3201,7 +3201,7 @@ func resolveUpstreamModelForOpenAICompatAPIKey(cfg *internalconfig.Config, auth
32013201 providerKey = strings .TrimSpace (auth .Attributes ["provider_key" ])
32023202 compatName = strings .TrimSpace (auth .Attributes ["compat_name" ])
32033203 }
3204- if compatName == "" && ! strings . EqualFold ( strings . TrimSpace ( auth .Provider ), "openai-compatibility" ) {
3204+ if compatName == "" && ! util . IsOpenAICompatibleProvider ( auth .Provider ) {
32053205 return ""
32063206 }
32073207 entry := resolveOpenAICompatConfig (cfg , providerKey , compatName , auth .Provider )
@@ -3217,15 +3217,23 @@ func resolveOpenAICompatConfig(cfg *internalconfig.Config, providerKey, compatNa
32173217 if cfg == nil {
32183218 return nil
32193219 }
3220- candidates := make ([]string , 0 , 3 )
3221- if v := strings .TrimSpace (compatName ); v != "" {
3222- candidates = append (candidates , v )
3223- }
3224- if v := strings .TrimSpace (providerKey ); v != "" {
3225- candidates = append (candidates , v )
3220+ candidates := make ([]string , 0 , 6 )
3221+ seen := make (map [string ]struct {}, 6 )
3222+ addCandidate := func (value string ) {
3223+ value = strings .TrimSpace (value )
3224+ if value == "" {
3225+ return
3226+ }
3227+ key := strings .ToLower (value )
3228+ if _ , ok := seen [key ]; ok {
3229+ return
3230+ }
3231+ seen [key ] = struct {}{}
3232+ candidates = append (candidates , value )
32263233 }
3227- if v := strings .TrimSpace (authProvider ); v != "" {
3228- candidates = append (candidates , v )
3234+ for _ , value := range []string {compatName , providerKey , authProvider } {
3235+ addCandidate (value )
3236+ addCandidate (util .OpenAICompatibleProviderName (value ))
32293237 }
32303238 for i := range cfg .OpenAICompatibility {
32313239 compat := & cfg .OpenAICompatibility [i ]
0 commit comments