Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/plugin/scripts/calibrate-tokenizer/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@
"provider": "openrouter",
"modelId": "anthropic/claude-sonnet-4.6",
"tokenizerKey": "anthropic/claude-sonnet-4.5"
},
{
"label": "minimax/MiniMax-M3",
"provider": "minimax",
"modelId": "MiniMax-M3",
"tokenizerKey": null
},
{
"label": "minimax/MiniMax-M2.7",
"provider": "minimax",
"modelId": "MiniMax-M2.7",
"tokenizerKey": null
},
{
"label": "minimax-cn/MiniMax-M3",
"provider": "minimax-cn",
"modelId": "MiniMax-M3",
"tokenizerKey": null
},
{
"label": "minimax-cn/MiniMax-M2.7",
"provider": "minimax-cn",
"modelId": "MiniMax-M2.7",
"tokenizerKey": null
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { afterEach, describe, expect, it } from "bun:test";
import { readFileSync } from "node:fs";

import { measureOpenAICompatible } from "./openai-compatible";

const originalFetch = globalThis.fetch;
const modelCatalog = JSON.parse(
readFileSync(new URL("../models.json", import.meta.url), "utf-8"),
) as {
tests: Array<{ provider: string; modelId: string }>;
};

afterEach(() => {
globalThis.fetch = originalFetch;
});

async function expectProviderEndpoint(provider: string, expectedUrl: string): Promise<void> {
const urls: string[] = [];
const totals = [10, 30, 50];
globalThis.fetch = (async (input: string | URL | Request) => {
urls.push(String(input));
const promptTokens = totals[urls.length - 1];
return new Response(JSON.stringify({ usage: { prompt_tokens: promptTokens } }), {
status: 200,
headers: { "content-type": "application/json" },
});
}) as typeof fetch;

const result = await measureOpenAICompatible(
{
label: `${provider}/MiniMax-M3`,
provider,
modelId: "MiniMax-M3",
},
{ type: "api", key: "test-key" },
"system prompt",
[{ name: "tool", description: "Tool", input_schema: { type: "object" } }],
);

expect(urls).toEqual([expectedUrl, expectedUrl, expectedUrl]);
expect(result).toEqual({ systemApi: 20, toolsApi: 40 });
}

describe("measureOpenAICompatible", () => {
it("catalogs both current MiniMax models for each regional route", () => {
for (const provider of ["minimax", "minimax-cn"]) {
const modelIds = modelCatalog.tests
.filter((test) => test.provider === provider)
.map((test) => test.modelId);
expect(modelIds).toEqual(["MiniMax-M3", "MiniMax-M2.7"]);
}
});

it("routes MiniMax global calibration requests", async () => {
await expectProviderEndpoint(
"minimax",
"https://api.minimax.io/v1/chat/completions",
);
});

it("routes MiniMax China calibration requests", async () => {
await expectProviderEndpoint(
"minimax-cn",
"https://api.minimaxi.com/v1/chat/completions",
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ function endpointFor(provider: string, auth: AuthEntry): ProviderEndpoint {
maxTokensField: "max_tokens",
supportsTools: true,
};
case "minimax":
return {
url: "https://api.minimax.io/v1/chat/completions",
headers,
maxTokensField: "max_tokens",
supportsTools: true,
};
case "minimax-cn":
return {
url: "https://api.minimaxi.com/v1/chat/completions",
headers,
maxTokensField: "max_tokens",
supportsTools: true,
};
default:
throw new Error(`Unknown provider: ${provider}`);
}
Expand Down