File size: 1,394 Bytes
116a473
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { describe, expect, test } from "bun:test"
import { ZenData } from "../src/model"

const base = {
  zenModels: {
    "gpt-5.6-sol": {
      name: "GPT-5.6 Sol",
      cost: { input: 2, output: 10 },
      costMultiplier: 1,
      providers: [{ id: "openai", model: "gpt-5.6-sol" }],
    },
  },
  liteModels: {},
  providers: { openai: { api: "https://api.openai.com/v1", apiKey: "test" } },
}

const entry = (data: ReturnType<typeof ZenData.validate>) => {
  const value = data.zenModels["gpt-5.6-sol"]
  return Array.isArray(value) ? value[0] : value
}

describe("ZenData cost200K threshold", () => {
  test("defaults to 200_000 when not configured", () => {
    const data = ZenData.validate({
      ...base,
      zenModels: {
        "gpt-5.6-sol": {
          ...base.zenModels["gpt-5.6-sol"],
          // The secret arrives as parsed JSON in production, so untyped here too.
          cost200K: JSON.parse('{"input":4,"output":15}'),
        },
      },
    })
    expect(entry(data).cost200K?.threshold).toBe(200_000)
  })

  test("accepts an explicit 272_000 threshold", () => {
    const data = ZenData.validate({
      ...base,
      zenModels: {
        "gpt-5.6-sol": {
          ...base.zenModels["gpt-5.6-sol"],
          cost200K: { input: 4, output: 15, threshold: 272_000 },
        },
      },
    })
    expect(entry(data).cost200K?.threshold).toBe(272_000)
  })
})