77 * to measure how well CanopyWave caches the shared prefix across turns.
88 *
99 * Usage:
10- * bun scripts/test-canopywave-long.ts
10+ * bun scripts/test-canopywave-long.ts [model]
11+ *
12+ * Models:
13+ * minimax (default) — minimax/minimax-m2.5
14+ * kimi — moonshotai/kimi-k2.6
1115 */
1216
1317export { }
1418
1519const CANOPYWAVE_BASE_URL = 'https://inference.canopywave.io/v1'
16- const CANOPYWAVE_MODEL = 'minimax/minimax-m2.5'
1720
18- // Pricing constants — same model as Fireworks/SiliconFlow
19- const INPUT_COST_PER_TOKEN = 0.30 / 1_000_000
20- const CACHED_INPUT_COST_PER_TOKEN = 0.03 / 1_000_000
21- const OUTPUT_COST_PER_TOKEN = 1.20 / 1_000_000
21+ type ModelConfig = {
22+ id : string
23+ inputCostPerToken : number
24+ cachedInputCostPerToken : number
25+ outputCostPerToken : number
26+ }
27+
28+ const MODEL_CONFIGS : Record < string , ModelConfig > = {
29+ minimax : {
30+ id : 'minimax/minimax-m2.5' ,
31+ inputCostPerToken : 0.30 / 1_000_000 ,
32+ cachedInputCostPerToken : 0.03 / 1_000_000 ,
33+ outputCostPerToken : 1.20 / 1_000_000 ,
34+ } ,
35+ kimi : {
36+ // Pricing is approximate — based on public Moonshot k2 rates; CanopyWave may differ.
37+ id : 'moonshotai/kimi-k2.6' ,
38+ inputCostPerToken : 0.60 / 1_000_000 ,
39+ cachedInputCostPerToken : 0.15 / 1_000_000 ,
40+ outputCostPerToken : 2.50 / 1_000_000 ,
41+ } ,
42+ }
43+
44+ const MODEL_ALIASES : Record < string , keyof typeof MODEL_CONFIGS > = {
45+ 'minimax/minimax-m2.5' : 'minimax' ,
46+ 'moonshotai/kimi-k2.6' : 'kimi' ,
47+ 'kimi-k2.6' : 'kimi' ,
48+ }
49+
50+ const DEFAULT_MODEL = 'minimax'
51+ const modelArg = process . argv [ 2 ]
52+ const modelKey = modelArg ? ( MODEL_ALIASES [ modelArg ] ?? modelArg ) : DEFAULT_MODEL
53+ const MODEL = MODEL_CONFIGS [ modelKey ]
54+ if ( ! MODEL ) {
55+ console . error ( `❌ Unknown model: "${ modelKey } ". Available: ${ Object . keys ( MODEL_CONFIGS ) . join ( ', ' ) } ` )
56+ process . exit ( 1 )
57+ }
58+ const CANOPYWAVE_MODEL = MODEL . id
59+ const INPUT_COST_PER_TOKEN = MODEL . inputCostPerToken
60+ const CACHED_INPUT_COST_PER_TOKEN = MODEL . cachedInputCostPerToken
61+ const OUTPUT_COST_PER_TOKEN = MODEL . outputCostPerToken
2262
23- const MAX_TOKENS = 100
63+ // Higher cap accounts for reasoning models (e.g. kimi-k2.6) that consume tokens
64+ // on hidden reasoning before producing visible content.
65+ const MAX_TOKENS = 10000
2466
2567function computeCost ( usage : Record < string , unknown > ) : { cost : number ; breakdown : string } {
2668 const inputTokens = typeof usage . prompt_tokens === 'number' ? usage . prompt_tokens : 0
@@ -35,9 +77,9 @@ function computeCost(usage: Record<string, unknown>): { cost: number; breakdown:
3577 const totalCost = inputCost + cachedCost + outputCost
3678
3779 const breakdown = [
38- `${ nonCachedInput } non-cached input × $0.30 /M = $${ inputCost . toFixed ( 8 ) } ` ,
39- `${ cachedTokens } cached input × $0.03 /M = $${ cachedCost . toFixed ( 8 ) } ` ,
40- `${ outputTokens } output × $1.20 /M = $${ outputCost . toFixed ( 8 ) } ` ,
80+ `${ nonCachedInput } non-cached input × $${ ( INPUT_COST_PER_TOKEN * 1_000_000 ) . toFixed ( 2 ) } /M = $${ inputCost . toFixed ( 8 ) } ` ,
81+ `${ cachedTokens } cached input × $${ ( CACHED_INPUT_COST_PER_TOKEN * 1_000_000 ) . toFixed ( 2 ) } /M = $${ cachedCost . toFixed ( 8 ) } ` ,
82+ `${ outputTokens } output × $${ ( OUTPUT_COST_PER_TOKEN * 1_000_000 ) . toFixed ( 2 ) } /M = $${ outputCost . toFixed ( 8 ) } ` ,
4183 `Total: $${ totalCost . toFixed ( 8 ) } ` ,
4284 ] . join ( '\n ' )
4385
@@ -275,7 +317,7 @@ async function main() {
275317 console . log ( `Base URL: ${ CANOPYWAVE_BASE_URL } ` )
276318 console . log ( `Max tokens: ${ MAX_TOKENS } (low output per turn)` )
277319 console . log ( `Turns: ${ TURN_PROMPTS . length } ` )
278- console . log ( `Pricing: $0.30 /M input, $0.03 /M cached, $1.20 /M output` )
320+ console . log ( `Pricing: $${ ( INPUT_COST_PER_TOKEN * 1_000_000 ) . toFixed ( 2 ) } /M input, $${ ( CACHED_INPUT_COST_PER_TOKEN * 1_000_000 ) . toFixed ( 2 ) } /M cached, $${ ( OUTPUT_COST_PER_TOKEN * 1_000_000 ) . toFixed ( 2 ) } /M output` )
279321 console . log ( '=' . repeat ( 60 ) )
280322 console . log ( )
281323
0 commit comments