fix(openai): do not normalize API token based accounts

This commit is contained in:
Alex
2026-04-07 11:27:57 +03:00
parent 9ab2fd7f9e
commit 7eecc49c3a
3 changed files with 47 additions and 2 deletions

View File

@@ -99,3 +99,39 @@ func TestNormalizeCodexModel(t *testing.T) {
}
}
}
func TestNormalizeOpenAIModelForUpstream(t *testing.T) {
tests := []struct {
name string
account *Account
model string
want string
}{
{
name: "oauth keeps codex normalization behavior",
account: &Account{Type: AccountTypeOAuth},
model: "gemini-3-flash-preview",
want: "gpt-5.1",
},
{
name: "apikey preserves custom compatible model",
account: &Account{Type: AccountTypeAPIKey},
model: "gemini-3-flash-preview",
want: "gemini-3-flash-preview",
},
{
name: "apikey preserves official non codex model",
account: &Account{Type: AccountTypeAPIKey},
model: "gpt-4.1",
want: "gpt-4.1",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := normalizeOpenAIModelForUpstream(tt.account, tt.model); got != tt.want {
t.Fatalf("normalizeOpenAIModelForUpstream(...) = %q, want %q", got, tt.want)
}
})
}
}