fix(reflection): recognize MiniMax regional endpoint and align provider id - #975
Conversation
…er id inferProviderFromBaseURL only matched the global api.minimax.io host and returned "minimax-portal", while an explicit "minimax/<model>" reference resolves the provider id to "minimax". The regional api.minimaxi.com host was not matched at all, so a bare model name (e.g. MiniMax-M3, MiniMax-M2.7) resolved to a different provider id depending on the configured region. Match both api.minimax.io and api.minimaxi.com with the existing "." + suffix spoofing guard and return "minimax" so bare-name reflection configuration is region-independent and consistent with the explicit modelRef path. Extend the regression test to cover both regional hosts and spoofing protection.
rwmjhb
left a comment
There was a problem hiding this comment.
Reviewed head 43a9711. The source-level targeted tests and full suite pass, but the published runtime does not contain this fix.
index.ts now recognizes .minimaxi.com and returns minimax, while the tracked dist/index.js at this same head still recognizes only .minimax.io and returns minimax-portal. package.json.main points installed plugins at dist/index.js, and this PR changes only index.ts plus the source-oriented test. As submitted, repository tests pass but installed/published users continue executing the old behavior.
Please run the project build, commit the resulting dist/index.js, and run npm run verify-package-runtime (or the equivalent package dry-run) so the generated delivery artifact is verified. A focused packaged-runtime assertion for both MiniMax hostnames would prevent this source/dist split from recurring.
Non-blocking compatibility follow-up: the existing .minimax.io return value changes from minimax-portal to minimax; an end-to-end provider consumer test would make that intentional contract change safer than helper-only expectations.
Reason: MiniMax reflection provider inference ignored the regional api.minimaxi.com endpoint and returned a provider id inconsistent with the explicit model-reference path, making bare-name configuration region-dependent.
What changed
inferProviderFromBaseURLnow recognizes both MiniMax base URLs —api.minimax.io(global) andapi.minimaxi.com(regional) — using the existing"." + suffixendsWithguard that blocks host spoofing (e.g.fake-minimax.io,fake-minimaxi.com).minimaxprovider id, matching the id parsed from an explicitminimax/<model>reference insplitProviderModel, so a bare model name such asMiniMax-M3orMiniMax-M2.7resolves to the same provider regardless of the configured region.Why
The global host previously mapped to
minimax-portalwhile the explicit model-reference path usedminimax, and the regional host was not matched at all. Bare-name reflection configuration was therefore region-dependent and inconsistent between the two resolution branches (split.provider ?? inferProviderFromBaseURL(...)).Tests
test/infer-provider-from-baseurl.test.mjswith the updated provider id, both regional hosts (/v1and/anthropicbase URLs), andfake-minimaxi.comspoofing protection.node --test test/infer-provider-from-baseurl.test.mjs— 13/13 pass.npx tsc -p tsconfig.json --noEmit— passes.