feat(models): track online pricing sources and unsupported fields

This commit is contained in:
ZheFox
2026-07-23 15:18:08 +08:00
parent 323273ff30
commit 1d2655432d
11 changed files with 549 additions and 242 deletions
@@ -63,6 +63,36 @@ describe('buildModelsDevTieredPricing', () => {
})
})
it('allows special token dimensions only when they use the base token price', () => {
expect(buildModelsDevTieredPricing({
input: 1,
output: 2,
input_audio: 1,
output_audio: 2,
reasoning: 2,
})).toEqual({
tiers: [{ up_to: null, input_price_per_1m: 1, output_price_per_1m: 2 }],
})
})
it.each([
{ input: 1, output: 2, reasoning: 4 },
{ input: 1, output: 2, input_audio: 3 },
{ input: 1, output: 2, output_audio: 5 },
{
input: 1,
output: 2,
tiers: [{
input: 3,
output: 4,
input_audio: 9,
tier: { type: 'context', size: 100_000 },
}],
},
])('rejects pricing dimensions the billing engine cannot settle independently', (cost) => {
expect(buildModelsDevTieredPricing(cost)).toBeNull()
})
it('omits an empty base band when context pricing starts at zero', () => {
expect(buildModelsDevTieredPricing({
input: 1,
@@ -51,6 +51,11 @@ describe('getModelsDevList', () => {
output: ['text'],
cost: { input: 1, output: 2 },
},
'audio-priced': {
id: 'audio-priced',
name: 'Audio Priced',
cost: { input: 1, output: 2, input_audio: 4 },
},
},
},
},
@@ -59,6 +64,7 @@ describe('getModelsDevList', () => {
const models = await getModelsDevList()
const current = models.find(model => model.modelId === 'gpt-test')
const legacy = models.find(model => model.modelId === 'legacy')
const audioPriced = models.find(model => model.modelId === 'audio-priced')
expect(current).toMatchObject({
supportsVision: true,
@@ -73,5 +79,11 @@ describe('getModelsDevList', () => {
inputModalities: ['text', 'image'],
outputModalities: ['text'],
})
expect(audioPriced).toMatchObject({
inputPrice: 1,
outputPrice: 2,
pricingUnsupportedFields: ['input_audio'],
})
expect(audioPriced?.tieredPricing).toBeUndefined()
})
})