A gateway key now carries ServiceTier: follow the request (unset), standard, Fast (priority) or Ultrafast. keyTiered sets the Responses and Chat request's service_tier to it, over the client's ask and Codex's own setting; standard takes the tier off and Ultrafast on a bare model no account lists it on goes as priority. What is sent upstream stays the providers' own rule (fits, takesTier, fallback), so a vendor with no service tier is sent none; Anthropic-protocol requests are untouched. Set with the tier-key action, `magpie gateway-key tier <id> ...`, or the key row's badge (zh, zh-TW, ja, de strings). Run (wsl-run, Linux): TestGatewayKeyServiceTier, TestKeyTieredChat, TestKeyServiceTier, TestGatewayKeyTierCLI green; internal/gui -run Key|Tier|Caller|Access ok; gateway-key-tier and gateway-key-concurrency GUI files 40 of 40 in chromium and webkit (serial); go vet nogui for linux, windows and darwin; gofmt clean. Broken by hand: with the keyTiered call removed TestGatewayKeyServiceTier fails on 4 rows. A parallel run of all gateway-key and i18n GUI files had 8 unrelated timeouts that pass serially (load). The whole internal/cli package hit the default 10m timeout on this box; the key tests in it pass. Not tried: a real ChatGPT account, the Windows box, the full suite.
34 lines
1.3 KiB
Go
34 lines
1.3 KiB
Go
package access
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// JackyFill on X: a gateway key can be set to a service tier. tier-key sets
|
|
// it (from the words people use too), Authenticate tells it, "follow" takes
|
|
// it off, and a word it doesn't know is refused with the key left as it was.
|
|
func TestKeyServiceTier(t *testing.T) {
|
|
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
|
|
clockAt(t, time.Date(2026, 11, 11, 9, 0, 0, 0, time.UTC))
|
|
id, secret := addKey(t, "Team")
|
|
if who, _ := Authenticate(secret); who.ServiceTier != "" {
|
|
t.Fatal("a new key has a tier:", who.ServiceTier)
|
|
}
|
|
for in, want := range map[string]string{"fast": "priority", "Ultra_Fast": "ultrafast", "normal": "default", "priority": "priority", "follow": "", "": ""} {
|
|
if _, err := Update("tier-key", Change{Key: id, ServiceTier: in}); err != nil {
|
|
t.Fatal(in, err)
|
|
}
|
|
if who, ok := Authenticate(secret); !ok || who.ServiceTier != want {
|
|
t.Fatalf("%q: tier %q, want %q", in, who.ServiceTier, want)
|
|
}
|
|
}
|
|
Update("tier-key", Change{Key: id, ServiceTier: "fast"})
|
|
if _, err := Update("tier-key", Change{Key: id, ServiceTier: "turbo"}); err == nil {
|
|
t.Fatal("turbo was taken")
|
|
}
|
|
if who, _ := Authenticate(secret); who.ServiceTier != "priority" {
|
|
t.Fatal("a refused word changed the key:", who.ServiceTier)
|
|
}
|
|
}
|