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:
1 parent
347311bfe5
commit
bc4e76db96
4 files changed
+269
-19
No files matched your search
@@ -2438,6 +2438,89 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// MiniMax e2e: Pi drives MiniMax through its Anthropic-compatible surface,
|
||||
/// so Kigi uses the Anthropic listing (x-api-key + anthropic-version,
|
||||
/// ?limit=1000) + Messages wire. /anthropic/v1/models is minimal, so
|
||||
/// enrichment supplies context; restrict=false keeps the clean MiniMax-M*
|
||||
/// catalog; id round-trips under the minimax key.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[serial_test::serial]
|
||||
async fn minimax_anthropic_listing_enriches_and_keys_under_platform() {
|
||||
let platform_server = wiremock::MockServer::start().await;
|
||||
wiremock::Mock::given(wiremock::matchers::method("GET"))
|
||||
.and(wiremock::matchers::path("/models"))
|
||||
// x-api-key auth (Anthropic key header) must be present.
|
||||
.and(wiremock::matchers::header("x-api-key", "mm-1"))
|
||||
.respond_with(wiremock::ResponseTemplate::new(200).set_body_json(
|
||||
// Anthropic listing envelope; minimal (id only) → enrichment fills.
|
||||
serde_json::json!({ "data": [
|
||||
{ "id": "MiniMax-M2.5", "type": "model" }
|
||||
], "has_more": false }),
|
||||
))
|
||||
.expect(1)
|
||||
.mount(&platform_server)
|
||||
.await;
|
||||
let modelsdev_server = wiremock::MockServer::start().await;
|
||||
wiremock::Mock::given(wiremock::matchers::method("GET"))
|
||||
.and(wiremock::matchers::path("/api.json"))
|
||||
.respond_with(wiremock::ResponseTemplate::new(200).set_body_json(
|
||||
serde_json::json!({ "minimax": { "models": {
|
||||
"MiniMax-M2.5": {
|
||||
"limit": {"context": 204800, "output": 131072},
|
||||
"tool_call": true
|
||||
}
|
||||
}}}),
|
||||
))
|
||||
.expect(1)
|
||||
.mount(&modelsdev_server)
|
||||
.await;
|
||||
let cache_dir = tempfile::tempdir().unwrap();
|
||||
let _base = kigi_test_support::EnvGuard::set(
|
||||
kigi_models::MINIMAX_BASE_URL_ENV,
|
||||
platform_server.uri(),
|
||||
);
|
||||
let _mdev = kigi_test_support::EnvGuard::set(
|
||||
crate::agent::enrichment_fetch::MODELS_DEV_URL_ENV,
|
||||
format!("{}/api.json", modelsdev_server.uri()),
|
||||
);
|
||||
let _mdev_cache = kigi_test_support::EnvGuard::set(
|
||||
crate::agent::enrichment_fetch::MODELS_DEV_CACHE_DIR_ENV,
|
||||
cache_dir.path(),
|
||||
);
|
||||
let endpoints = crate::agent::config::EndpointsConfig::default();
|
||||
let keys = crate::agent::models::PlatformApiKeys::test_single(
|
||||
kigi_models::PlatformId::Minimax,
|
||||
"mm-1",
|
||||
);
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
fetch_platform_models_blocking(&endpoints, None, &keys)
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
.expect("fetch must succeed");
|
||||
assert_eq!(
|
||||
result
|
||||
.models
|
||||
.iter()
|
||||
.map(|m| m.id.as_deref().unwrap_or_default())
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["minimax/MiniMax-M2.5"],
|
||||
"the Anthropic-listed model is keyed under the minimax platform"
|
||||
);
|
||||
let entry = &result.models[0];
|
||||
assert_eq!(
|
||||
entry.context_window.get(),
|
||||
204_800,
|
||||
"context comes from enrichment (the wire listing carries none)"
|
||||
);
|
||||
assert_eq!(entry.max_completion_tokens, Some(131_072));
|
||||
assert_eq!(entry.model, "MiniMax-M2.5");
|
||||
assert_eq!(
|
||||
kigi_models::parse_managed_model_key(entry.id.as_deref().unwrap()),
|
||||
Some((kigi_models::PlatformId::Minimax, "MiniMax-M2.5")),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn get_env_keys_parses_strings_and_rejects_non_strings() {
|
||||
use crate::agent::config::EnvKeys;
|
||||
|
||||
Reference in new issue
Block a user