fix(ai): correct Kimi K3 Moonshot pricing

This commit is contained in:
Armin Ronacher
2026-07-16 20:37:48 +02:00
parent c1b7856e26
commit aba324504c
6 changed files with 30 additions and 10 deletions
+1
View File
@@ -4,6 +4,7 @@
### Fixed
- Fixed Kimi K3 pricing metadata for Moonshot AI and Moonshot AI China.
- Fixed Kimi Coding K3 thinking-level metadata to expose only the supported `max` level ([#6737](https://github.com/earendil-works/pi/issues/6737)).
- Fixed catalog generation restoring xAI models removed in 0.80.9 ([#6736](https://github.com/earendil-works/pi/issues/6736)).
+10 -4
View File
@@ -235,6 +235,12 @@ const KIMI_K3_THINKING_LEVEL_MAP = {
max: "max",
} as const;
const KIMI_K3_MAX_TOKENS = 131072;
const KIMI_K3_COST = {
input: 3,
output: 15,
cacheRead: 0.3,
cacheWrite: 0,
} as const;
const OPENROUTER_KIMI_K3_MODEL_IDS = new Set(["moonshotai/kimi-k3", "~moonshotai/kimi-latest"]);
const ANT_LING_RING_THINKING_LEVEL_MAP = {
@@ -1701,10 +1707,10 @@ async function loadModelsDevData(): Promise<Model<any>[]> {
...(isKimiK3 ? { thinkingLevelMap: KIMI_K3_THINKING_LEVEL_MAP } : {}),
input: m.modalities?.input?.includes("image") ? ["text", "image"] : ["text"],
cost: {
input: m.cost?.input || 0,
output: m.cost?.output || 0,
cacheRead: m.cost?.cache_read || 0,
cacheWrite: m.cost?.cache_write || 0,
input: m.cost?.input || (isKimiK3 ? KIMI_K3_COST.input : 0),
output: m.cost?.output || (isKimiK3 ? KIMI_K3_COST.output : 0),
cacheRead: m.cost?.cache_read || (isKimiK3 ? KIMI_K3_COST.cacheRead : 0),
cacheWrite: m.cost?.cache_write || (isKimiK3 ? KIMI_K3_COST.cacheWrite : 0),
},
contextWindow: m.limit?.context || 4096,
maxTokens: m.limit?.output || 4096,
@@ -179,9 +179,9 @@ export const MOONSHOTAI_CN_MODELS = {
thinkingLevelMap: {"off":null,"minimal":null,"low":null,"medium":null,"high":null,"xhigh":null,"max":"max"},
input: ["text", "image"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
input: 3,
output: 15,
cacheRead: 0.3,
cacheWrite: 0,
},
contextWindow: 1048576,
@@ -179,9 +179,9 @@ export const MOONSHOTAI_MODELS = {
thinkingLevelMap: {"off":null,"minimal":null,"low":null,"medium":null,"high":null,"xhigh":null,"max":"max"},
input: ["text", "image"],
cost: {
input: 0,
output: 0,
cacheRead: 0,
input: 3,
output: 15,
cacheRead: 0.3,
cacheWrite: 0,
},
contextWindow: 1048576,
+12
View File
@@ -44,6 +44,18 @@ describe("builtin providers", () => {
}
});
it("uses official Kimi K3 pricing for Moonshot providers", () => {
const models = builtinModels();
for (const provider of ["moonshotai", "moonshotai-cn"]) {
expect(models.getModel(provider, "kimi-k3")?.cost).toEqual({
input: 3,
output: 15,
cacheRead: 0.3,
cacheWrite: 0,
});
}
});
it("resolves anthropic auth from env with OAuth token precedence", async () => {
const models = createModels({
authContext: fakeAuthContext({ ANTHROPIC_API_KEY: "key", ANTHROPIC_OAUTH_TOKEN: "oauth-token" }),
+1
View File
@@ -4,6 +4,7 @@
### Fixed
- Fixed inherited Kimi K3 pricing metadata for Moonshot AI and Moonshot AI China.
- Fixed inherited catalog generation restoring xAI models removed in 0.80.9 ([#6736](https://github.com/earendil-works/pi/issues/6736)).
## [0.80.9] - 2026-07-16