provider: a Kimi Code membership's k3.1-pro and k3.1-pro-highspeed are priced at the Kimi API's (#4635)
hlyx1's fix (#4635, branch hlyx1/magpie kimi-code-k31-pro-price), asked to be expedited by matrix0487 on Discord. Kimi Code's plans serve k3.1-pro and k3.1-pro-highspeed, which models.dev's kimi-code-plan-* catalogs list at the membership's $0. Neither id was in kimiCodeAPI, so a membership's call on either was unpriced on Usage. They now map to kimi-k3.1-pro and kimi-k3.1-pro-highspeed, like k3 to kimi-k3, and the Requests list names that model (PricedNameFor). Checked: Kimi Code's own /models answer (internal/catalog/testdata/ kimi-code-cn-models-2026-10-31.json) lists k3.1-pro "K3.1 Pro" and k3.1-pro-highspeed "K3.1 Pro Highspeed". Kimi's pricing page (platform.kimi.ai/docs/pricing/chat, read 2026-11-01) and models.dev's live moonshotai entry both give kimi-k3.1-pro $2 in / $10 out / $0.20 cached / $2 5m write, and kimi-k3.1-pro-highspeed $4 / $20 / $0.20 / $4. The fixture's new entries match models.dev's api.json in id, name, cost and canonical_model_id. The alias stays Kimi Code's (kimiCodePlans): the test's relay catalog now lists a k3.1-pro of its own at $0.50/$1, which keeps that price, and PricedNameFor(relay, k3.1-pro) stays k3.1-pro. Docs: docs/reference.md, docs/subsystems/providers-accounts.md. Run on mote (Go 1.26.8), at this change rebased onfb3942ee6(the pushed head adds only784b66366, app.js and a GUI test): gofmt -l clean; go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./... ok; go test -count=1 -timeout 45m for internal/provider, usage, gateway, agent, cli, routes, sessions, usageapi: all ok. TestKimiCodeListPrice and TestKimiCodeCost red with models.go at origin/main (k3.1-pro {0 0 0 0} false; kimi-code-cn/k3.1-pro priced=false cost=0, want true 3.264), green with it. Taking the kimiCodeMember() check out by hand turns PricedNameFor(relay, k3.1-pro) into kimi-k3.1-pro and the test red. Full go test ./... at baseda0005df8: every package ok but internal/gui, red on TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and TestMainWindowCorners/macOS_26_SDK (#3949), both open on main and not touched here. Not tried: a real Kimi Code membership's k3.1-pro call through the GUI.
This commit is contained in:
+2
-1
@@ -1280,7 +1280,8 @@ one with `magpie model price`, or in the provider's editor under the model.
|
||||
|
||||
A **Kimi Code** membership's models are counted at the Kimi API model each
|
||||
one is, not at the $0 models.dev lists them at for the plan: `k3` and
|
||||
`k3-256k` at `kimi-k3`, `kimi-for-coding-highspeed` at
|
||||
`k3-256k` at `kimi-k3`, `k3.1-pro` at `kimi-k3.1-pro`, `k3.1-pro-highspeed`
|
||||
at `kimi-k3.1-pro-highspeed`, `kimi-for-coding-highspeed` at
|
||||
`kimi-k2.7-code-highspeed`. `kimi-for-coding` is K2.8 Preview, which the API
|
||||
doesn't sell, so it has no price until you give it one
|
||||
(`magpie model price kimi-code/kimi-for-coding …`).
|
||||
|
||||
@@ -61,7 +61,7 @@ keys and accounts per request is in [Gateway routing and fallback](gateway-routi
|
||||
| A relay's Codex entries | A provider the user added by its address with a Responses URL may list its models in Codex's own shape (`slug`, `supported_reasoning_levels`, `shell_type`, `base_instructions`: `catalog.CodexEntry`), plainly or when asked with Codex's `client_version`, as sub2api does (ctopsc on Discord: GPT-6.1 Terra was handed models.dev's 922000 window where the relay said 272000). `fetchOne` keeps such a row whole (`catalog.Model.Codex`, with its window, max window and inputs read off it), and when the plain list has none it asks the same URL once more with `client_version` (`codexEntries`): only where the list is fetched (add, key change, Refresh), never per Codex poll. The answer only adds entries to models the plain list has; one that fails or can't be read keeps the last list's entries (failed read = unknown), one that answers plainly says there are none. `codexcat.listedEntry` hands Codex the relay's entry as given, `base_instructions` included, with magpie's slug, name, priority and " via magpie" description; the user's window, compaction, levels and image setting still win (levels keep the relay's descriptions). A saved list from before is enriched at its next Refresh. `TestCodexListedEntry`, `TestCodexListedEntryInPlainList`. | [`codex_entries.go`](../../internal/provider/codex_entries.go), [`live.go`](../../internal/catalog/live.go), [`codexcat.go`](../../internal/codexcat/codexcat.go) |
|
||||
| An endpoint's catalog | A key's provider with no catalog of its own (none named, none from a preset) is priced from the models.dev catalog whose `api` is one of its endpoints (`EndpointCatalog`, `catalog.AtEndpoint`; a trailing slash and case don't count, and an Anthropic base, kept as its root, is also matched with its `/v1`). Only when exactly one catalog is at that address, and it isn't a plan's (an id with `-plan`, or a `membershipCatalogs` one): a plan lists its membership's $0, and two catalogs at one address can't be told apart. A subscription's account never gets one. A provider at AMD's own endpoint is priced from `amd`, which lists Qwen3.8-27B at $0, a price, where its maker sells no such model and it had none (#2052); a relay's endpoint matches nothing and its model stays unpriced, never priced at a reseller's guess. `magpie model price` names the catalog, and says how to give a price when none is known. | [`models.go`](../../internal/provider/models.go), [`catalog.go`](../../internal/catalog/catalog.go) |
|
||||
| The maker's own price | A model priced at its maker (`MakerPrice`, a provider's `ListPrice` after its own catalog, `PricedName`; through `makerListPrice`) is priced at a models.dev provider that lists it as its own (`catalog.MakerPriced`): one whose entry's `canonical_model_id` names it as the maker, or whose id is the maker's with a region (`alibaba-cn`), never a plan's (`-plan`) and never at $0. A maker preset that is such an API is asked first, in preset order, then the other owners by id; only then the maker presets as before (`PricedBy`). A maker preset that resells another lab's model no longer prices it: Mistral's `deepseek-v4-1-flash-1017` at $0.30/$1.20 gave way to DeepSeek's $0.15/$0.60, and a lab that isn't a preset (Meta's `muse-spark`) is priced at all. So a subscription's model (Command Code's, bestony on Discord) is estimated at what its maker charges (`TestMakerPriceIsTheMakersOwn`). A model no maker lists (Kimi K2.5, GLM-5.2 Fast) stays unpriced; the user gives it a price or a same-as model. | [`models.go`](../../internal/provider/models.go), [`catalog.go`](../../internal/catalog/catalog.go) |
|
||||
| A membership's $0 catalog | models.dev lists every model of Kimi Code's plans (`kimi-code-plan-global`, `kimi-code-plan-cn`) and of Xiaomi MiMo's Token Plans (`xiaomi-token-plan-cn`, `-sgp`, `-ams`) at $0: what the membership charges per token, not what the model costs. `membershipCatalogs` are never read for a price (`priceCatalogs`, `makerPriceCatalogs`), so a Xiaomi MiMo model is priced at `xiaomi`'s list price at every region, and each region of the preset names its own catalog, pay as you go `xiaomi` alone (#1873). A Kimi Code provider's model is priced at the Kimi API model it is (`kimiCodeAPI`, from Kimi Code's docs: k3 and k3-256k are kimi-k3, kimi-for-coding-highspeed is kimi-k2.7-code-highspeed), and kimi-for-coding (K2.8 Preview, not on the API) is unpriced rather than free (#1370). The alias is Kimi Code's alone (`kimiCodePlans`): a relay's own `k3` keeps its own price. A catalog other than these that lists a model at $0 still prices it at $0: models.dev has truly free models (nvidia, modelscope). The Requests list names the API model it was priced as (`PricedNameFor`). | [`models.go`](../../internal/provider/models.go) |
|
||||
| A membership's $0 catalog | models.dev lists every model of Kimi Code's plans (`kimi-code-plan-global`, `kimi-code-plan-cn`) and of Xiaomi MiMo's Token Plans (`xiaomi-token-plan-cn`, `-sgp`, `-ams`) at $0: what the membership charges per token, not what the model costs. `membershipCatalogs` are never read for a price (`priceCatalogs`, `makerPriceCatalogs`), so a Xiaomi MiMo model is priced at `xiaomi`'s list price at every region, and each region of the preset names its own catalog, pay as you go `xiaomi` alone (#1873). A Kimi Code provider's model is priced at the Kimi API model it is (`kimiCodeAPI`, from Kimi Code's docs: k3 and k3-256k are kimi-k3, k3.1-pro and k3.1-pro-highspeed are kimi-k3.1-pro and kimi-k3.1-pro-highspeed, kimi-for-coding-highspeed is kimi-k2.7-code-highspeed), and kimi-for-coding (K2.8 Preview, not on the API) is unpriced rather than free (#1370). The alias is Kimi Code's alone (`kimiCodePlans`): a relay's own `k3` keeps its own price. A catalog other than these that lists a model at $0 still prices it at $0: models.dev has truly free models (nvidia, modelscope). The Requests list names the API model it was priced as (`PricedNameFor`). | [`models.go`](../../internal/provider/models.go) |
|
||||
| A plugin's own price | A model no catalog prices (models.dev has no vendor's own model: Devin's SWE-2 and SWE-1.7 Lightning, Cursor's auto, Qoder's efficient) is priced at what its plugin lists it at (`ListPrice` → `pluginListPrice`, `plugin.Model.Cost`, read by `pluginPrice`: an input or output above 0, OpenCode's 0 being none), else at $0 when the plugin says the plan serves it free (`pluginFree`, `plugin.Model.Free`: Devin's Free cost tier, Qoder's and WorkBuddy's x0). Both come after every catalog, so a price a catalog gives is kept over the plugin's. Devin's plugin (0.1.18) lists each paid model at the price Devin's GetCliModelConfigs gives it (input, cached input and output per 1M tokens); a moved Devin user's calls on Devin's own models had no cost on Usage before (太陽と向日葵 on Discord, `TestPluginFreeModelCostsNothing`). A plugin that gives no price and doesn't say free leaves the model unpriced. | [`models.go`](../../internal/provider/models.go), [`plugins.go`](../../internal/provider/plugins.go), [`providers.go`](../../internal/plugin/providers.go) |
|
||||
| Codex's free auto-review | OpenAI made Codex's Auto-review free for users signed in through a ChatGPT account (silverzhou on Discord), so a `codex-auto-review` call through the Codex subscription is priced at nothing (`ListPrice` → `codexReviewFree`, `provider.ChatGPTReviewFree`), not at GPT-5.6 Luna's price (`pricedNames`), and the Requests list names no model it is priced as (`PricedNameFor`). Not on a Free plan, where it spends the allowance (cybercaius), read from the plan Codex is signed in to now; a Codex signed out since counts as a paid plan, as the gateway's caps take it (`freeOnChatGPT`). The same model through an API key, the ChatGPT API subscription or a relay, and a review that followed the session to another model, keep their price; a price the user set wins. Every call is priced as it is read, so rows logged before are free too; the price views' cache keys on each account's plan (`usagePriceCacheKey`). Guarded by `TestAutoReviewFreeOnChatGPTSignIn` and `usage.TestAutoReviewFreeOnChatGPT`. |
|
||||
| A lab's models | models.dev keeps two catalogs: `api.json`, each provider's models with that host's prices, and `models.json`, each lab's models with only what is the model's on every host (name, window, reply limit, thinking, inputs, release), no price. `Sync` keeps the second beside the first as `labs.json` (`LabsPath`, `syncLabs`: best effort, through a rename, a failed fetch keeping the last; a catalog with none beside it is `Stale` once a process, so it comes at the next look). A model only a lab lists, no provider (models.dev took the gated Claude Mythos 5.1 out of anthropic's list in #11327 and kept its lab file), is voted into the same tables as a listed one (`loadGen`, `labs`), so `ContextOf`, `OutputOf`, `NameOf`, `Thinks`, `SeesImages` and every entry built on them know it wherever a vendor's or an account's list has it; a thinking one with no levels takes the levels of the newest of its family a provider gives them (`labKinEfforts`: Mythos 5.1 takes Mythos 5's). A model a provider lists keeps what providers say of it. `catalog.Describe` builds a model from these for a list that names an id alone. `TestLabOnlyModelIsKnown`, `TestLabsLeaveListedModels`, `TestSyncKeepsLabs`, `TestAnthropicKeyGatedModelDescribed` (iebb on Discord). | [`labs.go`](../../internal/catalog/labs.go), [`catalog.go`](../../internal/catalog/catalog.go) |
|
||||
|
||||
@@ -10,10 +10,11 @@ import (
|
||||
)
|
||||
|
||||
// useKimiCodeCatalog puts testdata/kimi_code_catalog.json in the catalog
|
||||
// cache: models.dev's own entries (2026-10-09) for moonshotai and both Kimi
|
||||
// Code plans, which list k3, k3-256k, kimi-for-coding and
|
||||
// kimi-for-coding-highspeed at $0, beside gpt-6-luna and a free OpenCode
|
||||
// model; plus a relay's catalog that lists a "k3" of its own at $0.
|
||||
// cache: models.dev's own entries (2026-10-31) for moonshotai and both Kimi
|
||||
// Code plans, which list k3, k3-256k, k3.1-pro, k3.1-pro-highspeed,
|
||||
// kimi-for-coding and kimi-for-coding-highspeed at $0, beside gpt-6-luna
|
||||
// and a free OpenCode model; plus a relay's catalog that lists a "k3" of
|
||||
// its own at $0 and a "k3.1-pro" of its own at $0.50 in, $1 out.
|
||||
func useKimiCodeCatalog(t *testing.T) {
|
||||
t.Helper()
|
||||
home := t.TempDir()
|
||||
@@ -30,7 +31,8 @@ func useKimiCodeCatalog(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m["freebie"] = map[string]any{"id": "freebie", "models": map[string]any{
|
||||
"k3": map[string]any{"id": "k3", "cost": map[string]any{"input": 0, "output": 0}}}}
|
||||
"k3": map[string]any{"id": "k3", "cost": map[string]any{"input": 0, "output": 0}},
|
||||
"k3.1-pro": map[string]any{"id": "k3.1-pro", "cost": map[string]any{"input": 0.5, "output": 1}}}}
|
||||
b, _ = json.Marshal(m)
|
||||
if err := os.MkdirAll(filepath.Dir(catalog.CachePath()), 0o700); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -49,13 +51,19 @@ func useKimiCodeCatalog(t *testing.T) {
|
||||
func TestKimiCodeListPrice(t *testing.T) {
|
||||
useKimiCodeCatalog(t)
|
||||
k3 := catalog.Price{Input: 3, Output: 15, CacheRead: 0.3, CacheWrite: 3}
|
||||
k31 := catalog.Price{Input: 2, Output: 10, CacheRead: 0.2, CacheWrite: 2}
|
||||
k31highspeed := catalog.Price{Input: 4, Output: 20, CacheRead: 0.2, CacheWrite: 4}
|
||||
highspeed := catalog.Price{Input: 1.9, Output: 8, CacheRead: 0.38}
|
||||
for _, preset := range []string{"kimi-code", "kimi-code-cn"} {
|
||||
p, err := FromPreset(preset)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for model, want := range map[string]catalog.Price{"k3": k3, "K3": k3, "k3-256k": k3, "kimi-for-coding-highspeed": highspeed} {
|
||||
for model, want := range map[string]catalog.Price{
|
||||
"k3": k3, "K3": k3, "k3-256k": k3,
|
||||
"k3.1-pro": k31, "K3.1-Pro": k31, "k3.1-pro-highspeed": k31highspeed,
|
||||
"kimi-for-coding-highspeed": highspeed,
|
||||
} {
|
||||
if pr, ok := p.ListPrice(model); !ok || !pr.Same(want) {
|
||||
t.Errorf("%s %s: %+v %v, want %+v", preset, model, pr, ok, want)
|
||||
}
|
||||
@@ -75,6 +83,10 @@ func TestKimiCodeListPrice(t *testing.T) {
|
||||
if pr, ok := relay.ListPrice("k3"); !ok || !pr.Same(catalog.Price{}) {
|
||||
t.Errorf("relay k3: %+v %v, want its own $0", pr, ok)
|
||||
}
|
||||
// and a relay's own k3.1-pro keeps its own price, not kimi-k3.1-pro's (#4635)
|
||||
if pr, ok := relay.ListPrice("k3.1-pro"); !ok || !pr.Same(catalog.Price{Input: 0.5, Output: 1}) {
|
||||
t.Errorf("relay k3.1-pro: %+v %v, want its own $0.50/$1", pr, ok)
|
||||
}
|
||||
// a model listed free elsewhere is still free, and Codex's still at its maker's
|
||||
zen := Provider{ID: "zen", Catalog: "opencode"}
|
||||
if pr, ok := zen.ListPrice("qwen3.6-plus-free"); !ok || !pr.Same(catalog.Price{}) {
|
||||
@@ -100,9 +112,18 @@ func TestKimiCodeListPrice(t *testing.T) {
|
||||
if got := PricedNameFor("kimi-code-cn", "k3-256k"); got != "kimi-k3" {
|
||||
t.Errorf("PricedNameFor(kimi-code-cn, k3-256k) = %q", got)
|
||||
}
|
||||
if got := PricedNameFor("kimi-code-cn", "k3.1-pro"); got != "kimi-k3.1-pro" {
|
||||
t.Errorf("PricedNameFor(kimi-code-cn, k3.1-pro) = %q", got)
|
||||
}
|
||||
if got := PricedNameFor("relay", "k3"); got != "k3" {
|
||||
t.Errorf("PricedNameFor(relay, k3) = %q", got)
|
||||
}
|
||||
if got := PricedNameFor("relay", "k3.1-pro"); got != "k3.1-pro" {
|
||||
t.Errorf("PricedNameFor(relay, k3.1-pro) = %q", got)
|
||||
}
|
||||
if got := PricedNameFor("kimi-code-cn", "k3.1-pro-highspeed"); got != "kimi-k3.1-pro-highspeed" {
|
||||
t.Errorf("PricedNameFor(kimi-code-cn, k3.1-pro-highspeed) = %q", got)
|
||||
}
|
||||
// free on a ChatGPT sign-in, so priced as nothing else (codexReviewFree)
|
||||
if got := PricedNameFor("codex", "codex-auto-review"); got != "codex-auto-review" {
|
||||
t.Errorf("PricedNameFor(codex, codex-auto-review) = %q", got)
|
||||
|
||||
@@ -2261,16 +2261,21 @@ func (p Provider) kimiCodeMember() bool {
|
||||
}
|
||||
|
||||
// kimiCodeAPI is the Kimi API model a Kimi Code model id is, as Kimi
|
||||
// Code's docs name it (https://www.kimi.com/code/docs/en/, 2026-10-09):
|
||||
// Code's docs name it (https://www.kimi.com/code/docs/en/, 2026-11-01):
|
||||
// k3 is K3, k3-256k "K3 256K context version … the same results as K3",
|
||||
// kimi-for-coding-highspeed "K2.7 Code HighSpeed". Kimi's API prices both
|
||||
// per token (https://platform.kimi.ai/docs/pricing/chat: kimi-k3 $3 in,
|
||||
// $15 out, $0.30 cached; kimi-k2.7-code-highspeed $1.90, $8, $0.38).
|
||||
// k3.1-pro "K3.1 Pro", k3.1-pro-highspeed "K3.1 Pro Highspeed", and
|
||||
// kimi-for-coding-highspeed "K2.7 Code HighSpeed". Kimi's API prices them
|
||||
// per token (https://platform.kimi.ai/docs/pricing/chat, as models.dev's
|
||||
// moonshotai entry lists them, read 2026-10-31: kimi-k3 $3 in, $15 out,
|
||||
// $0.30 cached; kimi-k3.1-pro $2, $10, $0.20; kimi-k3.1-pro-highspeed
|
||||
// $4, $20, $0.20; kimi-k2.7-code-highspeed $1.90, $8, $0.38).
|
||||
// kimi-for-coding is "K2.8 Preview", which the API doesn't sell, so it has
|
||||
// no API price and stays unpriced.
|
||||
var kimiCodeAPI = map[string]string{
|
||||
"k3": "kimi-k3",
|
||||
"k3-256k": "kimi-k3",
|
||||
"k3.1-pro": "kimi-k3.1-pro",
|
||||
"k3.1-pro-highspeed": "kimi-k3.1-pro-highspeed",
|
||||
"kimi-for-coding-highspeed": "kimi-k2.7-code-highspeed",
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,28 @@
|
||||
},
|
||||
"canonical_model_id": "moonshotai/kimi-k3"
|
||||
},
|
||||
"kimi-k3.1-pro": {
|
||||
"id": "kimi-k3.1-pro",
|
||||
"name": "Kimi K3.1 Pro",
|
||||
"cost": {
|
||||
"input": 2,
|
||||
"output": 10,
|
||||
"cache_read": 0.2,
|
||||
"cache_write": 2
|
||||
},
|
||||
"canonical_model_id": "moonshotai/kimi-k3.1-pro"
|
||||
},
|
||||
"kimi-k3.1-pro-highspeed": {
|
||||
"id": "kimi-k3.1-pro-highspeed",
|
||||
"name": "Kimi K3.1 Pro Highspeed",
|
||||
"cost": {
|
||||
"input": 4,
|
||||
"output": 20,
|
||||
"cache_read": 0.2,
|
||||
"cache_write": 4
|
||||
},
|
||||
"canonical_model_id": "moonshotai/kimi-k3.1-pro"
|
||||
},
|
||||
"kimi-k2.7-code-highspeed": {
|
||||
"id": "kimi-k2.7-code-highspeed",
|
||||
"name": "Kimi K2.7 Code HighSpeed",
|
||||
@@ -90,6 +112,28 @@
|
||||
"cache_write": 0
|
||||
},
|
||||
"canonical_model_id": "moonshotai/kimi-k3"
|
||||
},
|
||||
"k3.1-pro": {
|
||||
"id": "k3.1-pro",
|
||||
"name": "Kimi K3.1 Pro",
|
||||
"cost": {
|
||||
"input": 0,
|
||||
"output": 0,
|
||||
"cache_read": 0,
|
||||
"cache_write": 0
|
||||
},
|
||||
"canonical_model_id": "moonshotai/kimi-k3.1-pro"
|
||||
},
|
||||
"k3.1-pro-highspeed": {
|
||||
"id": "k3.1-pro-highspeed",
|
||||
"name": "Kimi K3.1 Pro Highspeed",
|
||||
"cost": {
|
||||
"input": 0,
|
||||
"output": 0,
|
||||
"cache_read": 0,
|
||||
"cache_write": 0
|
||||
},
|
||||
"canonical_model_id": "moonshotai/kimi-k3.1-pro"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -139,6 +183,28 @@
|
||||
"cache_write": 0
|
||||
},
|
||||
"canonical_model_id": "moonshotai/kimi-k3"
|
||||
},
|
||||
"k3.1-pro": {
|
||||
"id": "k3.1-pro",
|
||||
"name": "Kimi K3.1 Pro",
|
||||
"cost": {
|
||||
"input": 0,
|
||||
"output": 0,
|
||||
"cache_read": 0,
|
||||
"cache_write": 0
|
||||
},
|
||||
"canonical_model_id": "moonshotai/kimi-k3.1-pro"
|
||||
},
|
||||
"k3.1-pro-highspeed": {
|
||||
"id": "k3.1-pro-highspeed",
|
||||
"name": "Kimi K3.1 Pro Highspeed",
|
||||
"cost": {
|
||||
"input": 0,
|
||||
"output": 0,
|
||||
"cache_read": 0,
|
||||
"cache_write": 0
|
||||
},
|
||||
"canonical_model_id": "moonshotai/kimi-k3.1-pro"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -13,9 +13,10 @@ import (
|
||||
|
||||
// #1370 (maicent): the Usage page counted a Kimi Code membership's k3 at
|
||||
// ≈¥0.000, its plan's models.dev catalog listing every model at $0. A k3
|
||||
// call is now counted at Kimi's API price for kimi-k3, kimi-for-coding
|
||||
// (K2.8 Preview, which the API doesn't sell) is unpriced rather than free,
|
||||
// and a Moonshot pay-as-you-go call is what it was.
|
||||
// call is now counted at Kimi's API price for kimi-k3, a k3.1-pro one at
|
||||
// kimi-k3.1-pro's, kimi-for-coding (K2.8 Preview, which the API doesn't
|
||||
// sell) is unpriced rather than free, and a Moonshot pay-as-you-go call is
|
||||
// what it was.
|
||||
func TestKimiCodeCost(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
t.Setenv("HOME", home)
|
||||
@@ -45,6 +46,7 @@ func TestKimiCodeCost(t *testing.T) {
|
||||
// the reporter's k3 row: 240K in, 78.4K out, 10.0M cached
|
||||
in, out, cached := 240_000, 78_400, 10_000_000
|
||||
k3 := (float64(in)*3 + float64(out)*15 + float64(cached)*0.3) / 1e6
|
||||
k31 := (float64(in)*2 + float64(out)*10 + float64(cached)*0.2) / 1e6
|
||||
now := time.Now()
|
||||
calls := []struct {
|
||||
prov, model string
|
||||
@@ -52,6 +54,7 @@ func TestKimiCodeCost(t *testing.T) {
|
||||
want float64
|
||||
}{
|
||||
{"kimi-code-cn", "k3", true, k3},
|
||||
{"kimi-code-cn", "k3.1-pro", true, k31},
|
||||
{"kimi-code-cn", "kimi-for-coding", false, 0},
|
||||
{"moonshot", "kimi-k3", true, k3},
|
||||
}
|
||||
@@ -70,7 +73,7 @@ func TestKimiCodeCost(t *testing.T) {
|
||||
}
|
||||
}
|
||||
s := Summarize(Month)
|
||||
if s.Unpriced != 1 || math.Abs(s.Cost-2*k3) > 1e-9 || math.Abs(sum.Cost-2*k3) > 1e-9 {
|
||||
t.Fatalf("summary cost %v unpriced %d, ledger %v; want %v and 1", s.Cost, s.Unpriced, sum.Cost, 2*k3)
|
||||
if s.Unpriced != 1 || math.Abs(s.Cost-(2*k3+k31)) > 1e-9 || math.Abs(sum.Cost-(2*k3+k31)) > 1e-9 {
|
||||
t.Fatalf("summary cost %v unpriced %d, ledger %v; want %v and 1", s.Cost, s.Unpriced, sum.Cost, 2*k3+k31)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user