Skip to content

Commit c4ffff6

Browse files
committed
feat(calibration): add MiniMax provider routes
1 parent 7d22306 commit c4ffff6

3 files changed

Lines changed: 105 additions & 0 deletions

File tree

packages/plugin/scripts/calibrate-tokenizer/models.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,30 @@
132132
"provider": "openrouter",
133133
"modelId": "anthropic/claude-sonnet-4.6",
134134
"tokenizerKey": "anthropic/claude-sonnet-4.5"
135+
},
136+
{
137+
"label": "minimax/MiniMax-M3",
138+
"provider": "minimax",
139+
"modelId": "MiniMax-M3",
140+
"tokenizerKey": null
141+
},
142+
{
143+
"label": "minimax/MiniMax-M2.7",
144+
"provider": "minimax",
145+
"modelId": "MiniMax-M2.7",
146+
"tokenizerKey": null
147+
},
148+
{
149+
"label": "minimax-cn/MiniMax-M3",
150+
"provider": "minimax-cn",
151+
"modelId": "MiniMax-M3",
152+
"tokenizerKey": null
153+
},
154+
{
155+
"label": "minimax-cn/MiniMax-M2.7",
156+
"provider": "minimax-cn",
157+
"modelId": "MiniMax-M2.7",
158+
"tokenizerKey": null
135159
}
136160
]
137161
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import { afterEach, describe, expect, it } from "bun:test";
2+
import { readFileSync } from "node:fs";
3+
4+
import { measureOpenAICompatible } from "./openai-compatible";
5+
6+
const originalFetch = globalThis.fetch;
7+
const modelCatalog = JSON.parse(
8+
readFileSync(new URL("../models.json", import.meta.url), "utf-8"),
9+
) as {
10+
tests: Array<{ provider: string; modelId: string }>;
11+
};
12+
13+
afterEach(() => {
14+
globalThis.fetch = originalFetch;
15+
});
16+
17+
async function expectProviderEndpoint(provider: string, expectedUrl: string): Promise<void> {
18+
const urls: string[] = [];
19+
const totals = [10, 30, 50];
20+
globalThis.fetch = (async (input: string | URL | Request) => {
21+
urls.push(String(input));
22+
const promptTokens = totals[urls.length - 1];
23+
return new Response(JSON.stringify({ usage: { prompt_tokens: promptTokens } }), {
24+
status: 200,
25+
headers: { "content-type": "application/json" },
26+
});
27+
}) as typeof fetch;
28+
29+
const result = await measureOpenAICompatible(
30+
{
31+
label: `${provider}/MiniMax-M3`,
32+
provider,
33+
modelId: "MiniMax-M3",
34+
},
35+
{ type: "api", key: "test-key" },
36+
"system prompt",
37+
[{ name: "tool", description: "Tool", input_schema: { type: "object" } }],
38+
);
39+
40+
expect(urls).toEqual([expectedUrl, expectedUrl, expectedUrl]);
41+
expect(result).toEqual({ systemApi: 20, toolsApi: 40 });
42+
}
43+
44+
describe("measureOpenAICompatible", () => {
45+
it("catalogs both current MiniMax models for each regional route", () => {
46+
for (const provider of ["minimax", "minimax-cn"]) {
47+
const modelIds = modelCatalog.tests
48+
.filter((test) => test.provider === provider)
49+
.map((test) => test.modelId);
50+
expect(modelIds).toEqual(["MiniMax-M3", "MiniMax-M2.7"]);
51+
}
52+
});
53+
54+
it("routes MiniMax global calibration requests", async () => {
55+
await expectProviderEndpoint(
56+
"minimax",
57+
"https://api.minimax.io/v1/chat/completions",
58+
);
59+
});
60+
61+
it("routes MiniMax China calibration requests", async () => {
62+
await expectProviderEndpoint(
63+
"minimax-cn",
64+
"https://api.minimaxi.com/v1/chat/completions",
65+
);
66+
});
67+
});

packages/plugin/scripts/calibrate-tokenizer/providers/openai-compatible.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ function endpointFor(provider: string, auth: AuthEntry): ProviderEndpoint {
106106
maxTokensField: "max_tokens",
107107
supportsTools: true,
108108
};
109+
case "minimax":
110+
return {
111+
url: "https://api.minimax.io/v1/chat/completions",
112+
headers,
113+
maxTokensField: "max_tokens",
114+
supportsTools: true,
115+
};
116+
case "minimax-cn":
117+
return {
118+
url: "https://api.minimaxi.com/v1/chat/completions",
119+
headers,
120+
maxTokensField: "max_tokens",
121+
supportsTools: true,
122+
};
109123
default:
110124
throw new Error(`Unknown provider: ${provider}`);
111125
}

0 commit comments

Comments
 (0)