feat(providers): add MiniMax (global + China) via Anthropic Messages
Providers 21-22 (24th & 25th registry variants), sourced from Pi
(earendil-works/pi). Pi drives MiniMax through its Anthropic-COMPATIBLE
surface (baseUrl .../anthropic), so Kigi reuses the existing Anthropic
Messages machinery (wire_api=Messages, listing=Anthropic, key_header=XApiKey
x-api-key+anthropic-version) rather than the OpenAI path. Global:
api.minimax.io/anthropic, MINIMAX_API_KEY, models.dev minimax. China:
api.minimaxi.com/anthropic, MINIMAX_CN_API_KEY, models.dev minimax-cn.
The base carries the /v1 suffix (.../anthropic/v1) since Kigi appends bare
paths → listing .../anthropic/v1/models?limit=1000, inference
.../anthropic/v1/messages (matches the live-probed x-api-key-gated endpoint).
restrict_to_enriched=FALSE: the 7 MiniMax-M* models are clean (no pollution)
and restrict would drop launch-day models not yet in models.dev.
Also HARDENS parse_anthropic_listing to tolerate a bare array in addition to
the {data:[...]} envelope (mirrors parse_openai_listing's sniff that Together
taught us) — so MiniMax's Anthropic-compatible /models can't silently empty
the catalog if it serves a bare array. A bare object without data still errors.
Review found no defects (5 areas CONFIRMED incl. the /v1 non-doubling, the
additive parser change, restrict=false rationale). Residual (logged): the live
200 body / anthropic-version acceptance is unverifiable without a key; the
bare-array tolerance + restrict=false hedge most shapes.
Tests: e2e mocks the x-api-key-gated Anthropic listing (proves the auth header
+ enrichment + keying under minimax/); both validation tests reject 401 with
the per-variant console host; new parser test covers envelope + bare array +
bare-object-errors. Registry at 25; picker 26 rows.
This commit is contained in:
@@ -627,7 +627,9 @@ mod tests {
|
||||
"zai",
|
||||
"zai-coding-cn",
|
||||
"xiaomi",
|
||||
"xiaomi-token-plan-cn"
|
||||
"xiaomi-token-plan-cn",
|
||||
"minimax",
|
||||
"minimax-cn"
|
||||
]
|
||||
);
|
||||
assert_eq!(default_id(&built), Some(XAI_API_KEY_METHOD_ID));
|
||||
@@ -673,7 +675,9 @@ mod tests {
|
||||
"zai",
|
||||
"zai-coding-cn",
|
||||
"xiaomi",
|
||||
"xiaomi-token-plan-cn"
|
||||
"xiaomi-token-plan-cn",
|
||||
"minimax",
|
||||
"minimax-cn"
|
||||
]
|
||||
);
|
||||
assert_eq!(default_id(&built), Some(CACHED_TOKEN_AUTH_METHOD_ID));
|
||||
@@ -712,7 +716,9 @@ mod tests {
|
||||
"zai",
|
||||
"zai-coding-cn",
|
||||
"xiaomi",
|
||||
"xiaomi-token-plan-cn"
|
||||
"xiaomi-token-plan-cn",
|
||||
"minimax",
|
||||
"minimax-cn"
|
||||
]
|
||||
);
|
||||
assert_eq!(default_id(&built), Some(CACHED_TOKEN_AUTH_METHOD_ID));
|
||||
@@ -754,7 +760,9 @@ mod tests {
|
||||
"zai",
|
||||
"zai-coding-cn",
|
||||
"xiaomi",
|
||||
"xiaomi-token-plan-cn"
|
||||
"xiaomi-token-plan-cn",
|
||||
"minimax",
|
||||
"minimax-cn"
|
||||
]
|
||||
);
|
||||
assert_eq!(default_id(&built), None);
|
||||
@@ -1205,4 +1213,51 @@ mod tests {
|
||||
"Invalid API key for xiaomi-token-plan-cn \u{2014} check your key on xiaomimimo.com"
|
||||
);
|
||||
}
|
||||
|
||||
/// MiniMax (global): Anthropic-compatible /models is x-api-key-gated (401
|
||||
/// for a bad key) → validator. Confirms the XApiKey header path is used.
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn minimax_validates_against_models_and_rejects_bad_key() {
|
||||
use wiremock::matchers::{header, method, path};
|
||||
let server = wiremock::MockServer::start().await;
|
||||
wiremock::Mock::given(method("GET"))
|
||||
.and(path("/models"))
|
||||
.and(header("x-api-key", "mm-bad"))
|
||||
.respond_with(wiremock::ResponseTemplate::new(401))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
let _base = EnvGuard::set(kigi_models::MINIMAX_BASE_URL_ENV, &server.uri());
|
||||
let err = authenticate_platform_api_key(kigi_models::PlatformId::Minimax, Some("mm-bad"))
|
||||
.await
|
||||
.expect_err("a 401 from /models must reject the key");
|
||||
assert_eq!(
|
||||
err.message,
|
||||
"Invalid API key for minimax \u{2014} check your key on platform.minimax.io"
|
||||
);
|
||||
}
|
||||
|
||||
/// MiniMax (China): distinct base URL + console host.
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn minimax_cn_validates_against_models_and_rejects_bad_key() {
|
||||
use wiremock::matchers::{method, path};
|
||||
let server = wiremock::MockServer::start().await;
|
||||
wiremock::Mock::given(method("GET"))
|
||||
.and(path("/models"))
|
||||
.respond_with(wiremock::ResponseTemplate::new(401))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
let _base = EnvGuard::set(kigi_models::MINIMAX_CN_BASE_URL_ENV, &server.uri());
|
||||
let err =
|
||||
authenticate_platform_api_key(kigi_models::PlatformId::MinimaxCn, Some("mm-cn-bad"))
|
||||
.await
|
||||
.expect_err("a 401 from /models must reject the key");
|
||||
assert_eq!(
|
||||
err.message,
|
||||
"Invalid API key for minimax-cn \u{2014} check your key on platform.minimaxi.com"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user