Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2import { catalogRowToMeta, pricePerMillion } from './llmgateway'
3
4const minimax = {
5 id: 'minimax-m3.1-flash',
6 architecture: {
7 input_modalities: ['text', 'image'],
8 output_modalities: ['text'],
9 },
10 pricing: {
11 prompt: '0.15e-6',
12 completion: '0.6e-6',
13 input_cache_read: '0.015e-6',
14 },
15 context_length: 1048576,
16 max_output: 524288,
17 json_output: false,
18 structured_outputs: false,
19 providers: [
20 {
21 tools: true,
22 reasoning: true,
23 vision: true,
24 streaming: true,
25 reasoning_efforts: ['low', 'medium', 'high', 'xhigh', 'max'],
26 },
27 ],
28}
29
30describe('LLM Gateway catalog rows', () => {
31 it('scales per-token prices to USD per million', () => {
32 expect(pricePerMillion('2.0e-6')).toBe(2)
33 expect(pricePerMillion('0.15e-6')).toBe(0.15)
34 expect(pricePerMillion('0')).toBeUndefined()
35 })
36
37 it('maps reasoning efforts and prices for a chat row', () => {
38 const meta = catalogRowToMeta(minimax)
39 expect(meta?.pricing).toEqual({
40 input: { normal: 0.15, cached: 0.015 },
41 output: { normal: 0.6 },
42 })
43 expect(meta?.reasoning).toEqual({
44 levels: {
45 low: 'low',
46 medium: 'medium',
47 high: 'high',
48 xhigh: 'xhigh',
49 max: 'max',
50 },
51 budget: false,
52 })
53 expect(meta?.contextWindow).toBe(1048576)
54 expect(meta?.maxCompletionTokens).toBe(524288)
55 expect(meta?.features).toContain('tools')
56 expect(meta?.features).toContain('reasoning')
57 })
58
59 it('maps none to the off level', () => {
60 const meta = catalogRowToMeta({
61 ...minimax,
62 id: 'gpt-5.6-terra',
63 providers: [
64 {
65 reasoning: true,
66 reasoning_efforts: ['none', 'low', 'medium', 'high'],
67 },
68 ],
69 })
70 expect(meta?.reasoning?.levels).toEqual({
71 off: 'none',
72 low: 'low',
73 medium: 'medium',
74 high: 'high',
75 })
76 })
77
78 it('skips the custom row and provider-prefixed ids', () => {
79 expect(catalogRowToMeta({ id: 'custom' })).toBeNull()
80 expect(catalogRowToMeta({ id: 'openai/gpt-5.5' })).toBeNull()
81 expect(catalogRowToMeta({ id: '' })).toBeNull()
82 })
83})