AIStudio2API icon indicating copy to clipboard operation
AIStudio2API copied to clipboard

fill-first 能否支持自定义账户顺序? / Allow choosing the account order for fill-first

Open soloverd opened this issue 3 weeks ago • 1 comments

现象 / Current behavior

ROUTING_STRATEGY=fill-first 时,候选账户按账户 ID 排序(internal/aistudio/accounts.go 中按 ID 升序的 sort.Slice),所以总是先填满 ID 字母序最前的账户。API_KEY_ACCOUNTS 只能限制某个 key 可以用哪些账户,不能决定先后顺序。

With ROUTING_STRATEGY=fill-first, candidates are sorted by account ID (the ascending sort.Slice on ID in internal/aistudio/accounts.go), so the account whose ID sorts first alphabetically is always filled first. API_KEY_ACCOUNTS limits which accounts a key may use, but not their order.

实际场景 / Real case

希望平时只用主账户,主账户冷却、并发已满或不可用时再依次用备用账户。但如果主账户的 ID 按字母序排在备用账户之后,fill-first 会一直先消耗备用账户的额度。现在没有设置可以改变这个顺序。

I want requests to use a main account normally, and fall back to backup accounts in a fixed order only when the main one is cooling down, out of concurrency slots, or unavailable. But when the main account's ID sorts after a backup, fill-first keeps spending the backup's quota first. There is currently no setting to change this order.

期望 / Expected

fill-first 能按用户指定的账户顺序选择账户,未指定的账户排在后面(保持现在的 ID 顺序)。round-robin 不受影响。

Let fill-first pick accounts in a user-chosen order, with unlisted accounts after them in the current ID order. round-robin would be unchanged.

我在自己的私有版本里实现过这个(带单元测试)。如果您觉得这个需求合理,我可以按仓库的 PR 规范提交;如果您更希望用其他方式实现,或者觉得不需要,也完全理解。

I have implemented this in a private build (with unit tests). If this sounds reasonable, I can open a PR following the repository's PR guidelines; if you would rather solve it differently or not at all, that is fine too.

soloverd avatar Nov 08 '26 12:11 soloverd

Thanks! v0.3.3 added ACCOUNT_ORDER, and the v0.3.4 settings page lets me reorder accounts too. This fully covers the request.

soloverd avatar Nov 10 '26 11:11 soloverd